none
Could not load file or assembly in Visual Studio 2012, C#

    Question

  • Hello everybody,

    I’m working on a C# code on Visual Studio 2012 on Windows 7. My solution contains several projects.

    I recently added a new project in my solution, and added the dll of this new project in the references of 2 other projects in the solution (one of the being the startup project). The new project itself is referencing to several other projects that are not included in my solution.

    Building the projects in the solution works fine, but when I try to run the program (in Debug or in Release) I get an error. Here is the error:

     

    System.IO.FileNotFoundException was caught

      HResult=-2147024894

      Message=Could not load file or assembly 'ABCD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

      Source=NP

      FileName=ABCD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

      FusionLog==== Pre-bind state information ===

    LOG: User = MyCompany\MyName

    LOG: DisplayName = ABCD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

     (Fully-specified)

    LOG: Appbase = file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/

    LOG: Initial PrivatePath = NULL

    Calling assembly : NP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

    ===

    LOG: This bind starts in default load context.

    LOG: Using application configuration file: C:\Users\MyName\Documents\Visual Studio 2012\Projects\MyProgram\Analysis\bin\Debug\Analysis.vshost.exe.Config

    LOG: Using host configuration file:

    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.

    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).

    LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD.DLL.

    LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD/ABCD.DLL.

    LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD.EXE.

    LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD/ABCD.EXE.

     

      StackTrace:

           at NewProject.DATA.SetType(NP np, String code, OrderType orderT, MODEL MODELv)

           at NewProject.DATA.SetData(NP np, String no, String type, String law, String time, OrderType orderT, MODEL MODELv)

      InnerException:

     

    Analysis is my startup project.

    NewProject is the project I added recently to my solution.

    ABCD.dll is referenced in NewProject, but the project ABCD is not part of the solution itself.

    In this error, it is said that the AppBase is file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/

    However, when I look at the ABCD reference in NewProject, it says:

    Assembly ABCD

        C:\Users\MyName\Documents\Visual Studio 2012\Projects\np\bin\ABCD.dll

     

    Indeed, ABCD.dll in not in the AppBase address written in the error. But I never said it was there, and I don’t understand where this comes from.

    I tried to put ABCD.dll in the AppBase address the error is giving me. But each time I rebuild NewProject and (then) my startup project Analysis, ABCD.dll disappears from C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/

    I am quite new to Visual Studio. I probably did something wrong when adding my new project but I can’t understand what it is. If one of you has an idea regarding the method to solve this issue, please don’t hesitate to speak !

    • Moved by Amanda Zhu Thursday, August 29, 2013 5:17 AM
    Wednesday, August 28, 2013 9:41 AM

Answers

  • Please carefully read this topic about adding reference in Visual Studio:

    http://msdn.microsoft.com/en-us/library/vstudio/wkze6zky.aspx

    Try to add reference to the dlls already built with the NewProject in the startup project, that is all the dlls in the NewProject's bin/Debug folder. If you want to add reference to the NewProject but not the dlls already built,  add reference to the related np project at the same time.


    Caillen
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Thursday, August 29, 2013 10:58 AM
    Moderator

All replies

  • Hello,

    I have moved this thread to Visual C# forum for better response.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 29, 2013 5:18 AM
  • Please carefully read this topic about adding reference in Visual Studio:

    http://msdn.microsoft.com/en-us/library/vstudio/wkze6zky.aspx

    Try to add reference to the dlls already built with the NewProject in the startup project, that is all the dlls in the NewProject's bin/Debug folder. If you want to add reference to the NewProject but not the dlls already built,  add reference to the related np project at the same time.


    Caillen
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Thursday, August 29, 2013 10:58 AM
    Moderator
  • You try removing the reference to the assembly ABCD.dll and add it again in Visual Studio.
    Thursday, August 29, 2013 12:19 PM