I am working on a plugin assembly for a piece of third party software. My plugin references another assembly of mine which eventually references Dynamitey. Now, the other assembly works fine under other circumstances, but when used with the plugin it fails. The error is this:
14:58:57.545: AssemblyResolve looking for ImpromptuInterface, PublicKeyToken=0b1781c923b2975b, requesting assembly N/A
14:58:57.547: Could not resolve assembly ImpromptuInterface, PublicKeyToken=0b1781c923b2975b, trying redirect to self.
TargetInvocation exception: System.TypeInitializationException: The type initializer for 'Dynamitey.Dynamic' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'ImpromptuInterface, PublicKeyToken=0b1781c923b2975b' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) ---> System.IO.FileLoadException: A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at Dynamitey.DynamicObjects.LateType..ctor(String typeName)
at Dynamitey.Dynamic..cctor()
--- End of inner exception stack trace ---
at Dynamitey.Dynamic.InvokeGet(Object target, String name)
So when Dynamic.InvokeGet is called, it eventually tries to load (from file?) the assembly named ImpromptuInterface, which is some sort of dynamic assembly created inside Dynamic.cs, i.e. not something that can be loaded from file. Looking at the debug output, I suspect the problem is triggered by the way the 3rd party software resolves plugin assemblies.
If I create a test project and 'statically' reference the plugin assembly, the problem does not occur.
Now, I am not claiming that this is a bug as such in Dynamitey, but maybe it could be made immune to such a problem?