Jamie Cansdale reported a strange problem on the mailing list. His code ran successfully when run for the first time, but subsequent runs in the same process, but a different AppDomain failed with a ClassCastException.
He was kind enough to work with me to try and isolate the problem. So several hours and various private IKVM builds later, I was able to reproduce the root problem:
using System; using System.Runtime.CompilerServices; class Class1 { static void Main(string[] args) { RuntimeHelpers.GetHashCode(new Class1()); if(AppDomain.CurrentDomain.FriendlyName != "2nd") { AppDomain dom = AppDomain.CreateDomain("2nd"); dom.ExecuteAssembly(typeof(Class1).Assembly.Location); } } }
This code dies with a System.MissingMethodException! Yet another weird multi-AppDomain bug.
Fortunately, the work around is easy. Instead of using RuntimeHelpers.GetHashCode() to implement System.identityHashCode(), I've gone back to using some handcoded IL in map.xml to call System.Object.GetHashCode() non-virtually. This was also what I did on v1.0 of the CLR (where RuntimeHelpers.GetHashCode() didn't yet exist).
Powered by: newtelligence dasBlog 2.3.12105.0
© Copyright 2021, Jeroen Frijters
E-mail