CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Dynamic load Assembly from specific path

    Hi,

    I have been dynamically loading assemblies using this:

    // paramType is "NamesSpace.TypeName, AssemblyName"
    myType = Type.GetType(paramType);
    myObj = Activator.CreateInstance(myType);

    This works with my assembly being in the same bin path as my app. Now if there is a possibility that the assemblies can be loading from a different path, is there a way i can just change the paramType and load it from a different path without code changes.

    If i need to make code changes to do like an Assembly.Load instead, can it support both versions with same code - local load and path load of assembly?

    Thanks
    Jubin

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Dynamic load Assembly from specific path

    Hi there,

    Here is an option that you can apply without any code changes...I assume you wouldn't want to put the assembly into the GAC in which case you would go for the option #2. In essence the reason why it will work in all scenarios is because you can change the configuration in the config file and leave the code as it is. Without the configuration it will work for the assemblies in the bin folder. With the configuration your assembly could be anywhere.
    Last edited by nelo; April 6th, 2010 at 04:42 PM. Reason: Clarification.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured