Solved

Dynamic assembly load

Posted on 2011-09-08
6
383 Views
Last Modified: 2012-05-12
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)
            Return frmToLoad

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.

Any ideas?
0
Comment
  • 3
  • 2
6 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 36504954
> so trust issues should not be an issue.

Network shares get Local Intranet trust levels.  This is a .NET setting independent of the sharing rights and NTFS security.   Try using CasPol to fully trust the assembly on the network share then try your dynamic code again.

http://msdn.microsoft.com/en-us/library/zdc263t0(v=vs.80).aspx
0
 

Author Comment

by:AlwaysSomethingToLearn
ID: 36507626
Gave that a try to no effect. I used CasPol for the 2.0 framework as that is what the assembly is built for. I ran CasPol on the server, do I need to run it on the client as well?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36508048
I ran CasPol on the server, do I need to run it on the client as well?
No need to run it on the server. You should run it on the client and grant the network location.
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:AlwaysSomethingToLearn
ID: 36511618
Thanks for your help, that does it. One last question before closing - am I right in assuming that if the assembly was deployed to the GAC then any trust issues go away?
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 250 total points
ID: 36512134
Assemblies placed in the GAC have full trust by default, assuming the calling code does as well.
0
 

Author Closing Comment

by:AlwaysSomethingToLearn
ID: 36512695
Many thanks for your timely responses
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now