Reputation: 272
We have got the following setting: A IPlugin interface, which is being exposed by the main executable. The main executable (and the plugins) are located on a removable drive.
We are trying to load every dll in a Plugin directory:
For Each Type As Type In asm.GetTypes()
Trace(Type.ToString())
If GetType(IPlugin).IsAssignableFrom(Type) Then
loadedPlugin = asm.CreateInstance(Type.Namespace & "." & Type.Name)
End If
Next
However, it does not seem to find a matching class which implements IPlugin, althrough I can see there is one. If I try to force it to load the class via calling CreateInstance directly, I get a ReflectionTypeLoadException.
However, the auto detection process does work flawlessy when I run the application on a local drive.
I know that there can be a security problem with .NET Apps on removable/network drives, but no Security Exception is thrown. I've also got .NET Framework 4.0 installed.
The Plugin DLL is built against the newest version of the Plugin interface, therefore it does not seem to be a version mismatch.
The operating system is Windows 7 x64.
GetType(IPlugin).AssemblyQualifiedName: App.IPlugin, MainApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Type.GetInterface("IPlugin").AssemblyQualifiedName: App.IPlugin, MainApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
They both have the same result.
Workaround: If I copy the plugin assembly to a local drive, it does work. However, that is not a very nice solution. Maybe something better comes up.
Another thing I might have to point out: The .NET application is mainly a plugin itself, which is being called by a VB6 application natively.
Can someone help me?
Thank you very much :)
Upvotes: 1
Views: 147
Reputation: 272
The workaround "copy the plugin to the temp directory on the local drive" does work.
Upvotes: 0