MonoTouch 4.0 throwing ReflectionTypeLoadException using the simulator
Since updating a working MonoTouch 3.x app to MonoTouch 4.0, I have been getting the following error when attempting to start a Debug or Release build on the Simulator:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at MonoTouch.ObjCRuntime.Runtime.RegisterAssembly (System.Reflection.Assembly a) [0x00000] in <filename unknown>:0
The problem appears to be with System.Xml.Linq, however I have checked all projects and references, and this doesn't even appear to be a transitive reference from what I can tell. I just don't appear to be using this anywhere.
Exception Message is always "Could not load System.Xml.Linq.XNodeNavigator from System.Xml.Linq".
Anyone have any ideas?
The root cause is that the iOS simulator only update files, it never deletes them (even if you delete your app from the simulator).
This cause problems if you have some files (eg System.Xml.Linq) at one point and remove them later (directly or use the linker which can remove it). From there you'll have some old, stale files in your simulator app directory.
The next issue is that MonoTouch register all assemblies present in the directory. This means the stale one are registered too in the simulator. At this stage this can work (and you won't see an error) or this could fail (with the error you have above) because the stale assembly does not have everything it needs to be loaded properly.
The easiest workaround is to reset your iOS simulator, that will remove everything (all apps and all files).
链接地址: http://www.djcxy.com/p/51938.html上一篇: IPv6在编程级别的Windows