locked
Could not load assembly file

Answers

  • Hi,

     

    You can do 2 things,

     

    1) you can put your ClassLibary2.dll in GAC and try to run this application

    2) or take the ClassLibrar2.dll path as input to the application and use Assembly class to load it and use reflection to create instance of the classes inside the libary

     

    If you need any help (sample code) ask me.

     

    Cheers,

     

    Tuesday, September 04, 2007 1:09 PM
  • Hi hidarO,

     

    I downloaded your sample project from this website - http://www.alamuae.com/up/Folder-009/1188825817_WindowsApplication93.zip and tested it in my PC. I got the same error as you said "Could not load assembly file". It worked fine when I tried to set the "Copy Local" property of the reference ClassLibrary2.Dll for true.

     

    You said "I want Set Path manually When Startup my Program" in your post.  Do you mean to change the ClassLibrary2.Dll file path manually and load ClassLibrary2.Dll dynamically in your application?


    If you would like to load an assembly dynamically, you can try to consider SThotakura2's suggestions.
    Here are some materials for your reference:
    #1 Install an assembly to GAC:
    http://support.microsoft.com/kb/815808

     

    #2 Load an assembly dynamically
    http://msdn2.microsoft.com/en-us/library/x4cw969y.aspx

     

    Hope this helps,

     

    Citizens on the earth


     

    Wednesday, September 05, 2007 4:10 AM

All replies

  • So do you want to dynamically load your assembly at runtime?

    Tuesday, September 04, 2007 10:13 AM
  •  

    I, but in the  path of the dll file Alone .

     

    thanks

    Tuesday, September 04, 2007 10:27 AM
  • Hi,

     

    You can do 2 things,

     

    1) you can put your ClassLibary2.dll in GAC and try to run this application

    2) or take the ClassLibrar2.dll path as input to the application and use Assembly class to load it and use reflection to create instance of the classes inside the libary

     

    If you need any help (sample code) ask me.

     

    Cheers,

     

    Tuesday, September 04, 2007 1:09 PM
  • Hi hidarO,

     

    I downloaded your sample project from this website - http://www.alamuae.com/up/Folder-009/1188825817_WindowsApplication93.zip and tested it in my PC. I got the same error as you said "Could not load assembly file". It worked fine when I tried to set the "Copy Local" property of the reference ClassLibrary2.Dll for true.

     

    You said "I want Set Path manually When Startup my Program" in your post.  Do you mean to change the ClassLibrary2.Dll file path manually and load ClassLibrary2.Dll dynamically in your application?


    If you would like to load an assembly dynamically, you can try to consider SThotakura2's suggestions.
    Here are some materials for your reference:
    #1 Install an assembly to GAC:
    http://support.microsoft.com/kb/815808

     

    #2 Load an assembly dynamically
    http://msdn2.microsoft.com/en-us/library/x4cw969y.aspx

     

    Hope this helps,

     

    Citizens on the earth


     

    Wednesday, September 05, 2007 4:10 AM
  • thank you

    Wednesday, September 05, 2007 7:15 AM
  • So... if I understand correctly,  if you don't want to add an assembly to the GAC or dynamically load it you must set copy local to ture.  This doen't really make sense, at least for our situation. 

     

    We are building a three teir application which will be distrubuted and build apon by other companies.  Client, Server, Data(Sql Server).

     

    We have three different output directories.  Client, Server and Shared.  The Shared directory are assemblies used by both the Server and Client. It will be deployed with both. For instance, our architecture will be deployed to both server and client.  If copy local is true we will have one architecture.dll in client, one in server and one in shared.   Now there are three places that a developer could reference the architecture.dll, which could cause the assemblies to be come out of sync.  With out having to 1)load it dynamically, 2)add it to the GAC or 3)Tell every developer that uses our Architecture to only get it from the "Shared" directory and ignore the one right in the project output how do we insure that there is only one version of the architecture assembly?

     

    Thanks

    Jeff Sessions

     

    Monday, October 29, 2007 6:30 PM