fullserializer
fullserializer copied to clipboard
UWP + .NET Native, can't instantiate types.
Hello,
I wrote to you on the Unity forum with a similar issue, and also solved it (kinda). But now I've stumbled upon another issue with the solution I provided and thought maybe you had a better solution in mind. (The issue I'm referring to is this: http://forum.unity3d.com/threads/full-inspector-inspector-and-serialization-for-structs-dicts-generics-interfaces.224270/page-26#post-2697963)
The issue at hand: when building for UWP, it seems that you can't "dynamically" load assemblies as you do for other platforms. The suggested solution to the problem was that you load the assemblies which exists inside the installation folder. But since UWP apps now require one to use the .NET Native-"flag", the assemblies (more importantly the Assembly-CSharp.dll) won't exist in it's current form. Thus, trying to load ones classes during runtime will result in error since the classes won't be found in any assembly (at least not that I can find, it's kinda hard because you can't really see what's inside an unmanaged assembly).
I found a somewhat acceptable work-around, which I believe can be implemented in some other way. Currently in fsTypedCache.cs you do:
var assembly = typeof(object).GetTypeInfo().Assembly;
which doesn't really work, since "object" is part of (System) mscorlib.dll (or some other lib), and thus will return that Assembly, but that's not where my types are located. So a work-around would be to instead do something like:
var assembly = typeof(my.namespace.MySerializedClass).GetTypeInfo().Assembly;
In other words, we need to somehow do this in a "prettier" way.
EDIT: I haven't tried it, but it's possible that the following might also work (but you, as you can see, would still need to know which assemblies you need (in this case the assembly generated by Unity which contains your classes)).
var assembly = Assembly.Load("Assembly-CSharp.dll");