none
could not load file or assembly RRS feed

  • Question


  • Hi,

        I have an winform application, which is divided into 3 projects. Project A references to project B and project C, and project B is the main project (entry point). Project A is dynamically loaded during runtime using the app.config file defined in project B. The config file contains an item like the following.
           
        <add key="Plugin" value="B, B.Wrapper"/>

        And the code snippet that I'm using to dynamically load assembly A is listed below.

        ....
        string assemblyInfo = ConfigurationManager.AppSettings["Plugin"];
        string[] parts = assemblyInfo.Split(new char[]{','});
        Assembly a = Assembly.Load(parts[0]);
        Type t = a.GetType(parts[1]);
        object o = Activator.CreateInstance(t);
        .....
       
        If I put each assembly in one folder, assembly A will be loaded properly.

        But if I create a shortcut of the main assembly (B), put it on the desktop, and then db-click on the shortcut, the above code snippet will throw an exception saying that assembly B could not be found.

        Any help is appreciated. Thanks.

        Note that everything is developed using .net 2.0, and everything has only one version.
    Friday, January 18, 2008 3:31 AM

Answers

  • You need to give it more information about where to find the assemblies. Either provide that information in the code when you load the assembly or register the assembly in the GAC. By default your app will always look in its own working directory so that's why it worked when you ran it directly from there.

    Friday, January 18, 2008 5:35 AM