Dynamic assembly load
Posted on 2011-09-08
I use the system.reflection namespace from a VB2005 program to dynamically load forms from unreferenced assemblies. Code below:
Dim asmFormAssembly As System.Reflection.Assembly = System.Reflection.Assembly.LoadFrom(AssemblyName)
Dim typToLoad As Type = asmFormAssembly.GetType(FormName)
Dim objGeneric As Object = Activator.CreateInstance(typToLoad)
Dim frmToLoad As Form = CType(objGeneric, Form)
If the assembly name is something like "C:\folder\folder\MyApp.exe" and the form is "MyApp.frmDemo" everything works fine. However, if I set up a shared drive on a server (win2008), copy the assembly there and send assembly name "\\servername\sharename\MyApp.exe" I get the famous "object not set ot an instance of an object" error because typToLoad is returned as nothing in the above code.
The shared drive has full permissions for everone and is a simple share. It is not running under IIS so trust issues should not be an issue. The shared folder is accessible from the calling client and I can paste to it and delete from it from the client (XPpro SP3). Also, I can execute the exe assembly directly on the server.