I am having an issue with runtime loaded C# assemblies. I am packing code into AssetBundles by separately compiling it using Mono's complier into an assembly and then placing the assembly bytecode in a custom asset in the asset bundle.
My problems start if I use the assembly that unity produces (Assembly-CSharp.dll) for the project as a reference for my dll. Unity builds the project assembly using a random hash as the file name and then renames it to Assembly-CSharp.dll. The hash however gets stored internally as the assembly name. This hash changes every time, so when I load my assembly it looks for the original assembly name and doesn't find it. This means that I have to rebuild my assembly and rebuild the asset bundles every time Unity rebuilds the Assembly-CSharp.dll.
Is there any way around this? To force unity to use a constant name when building Assembly-CSharp.dll?
K, fixed this by registering to the AppDomain.CurrentDomain.AssemblyResolve event before loadin the assemblies and redirecting the request there.
answered Jan 21 '11 at 02:09 PM