How to add dll in c# project

后端 未结 3 495
误落风尘
误落风尘 2020-12-13 19:08

I am trying to add a [Science.dll] in my project which should be staright forward. But I am getting a problem. Can someone tell me why?

My C# projec

相关标签:
3条回答
  • 2020-12-13 19:46

    The DLL must be present at all times - as the name indicates, a reference only tells VS that you're trying to use stuff from the DLL. In the project file, VS stores the actual path and file name of the referenced DLL. If you move or delete it, VS is not able to find it anymore.

    I usually create a libs folder within my project's folder where I copy DLLs that are not installed to the GAC. Then, I actually add this folder to my project in VS (show hidden files in VS, then right-click and "Include in project"). I then reference the DLLs from the folder, so when checking into source control, the library is also checked in. This makes it much easier when more than one developer will have to change the project.

    (Please make sure to set the build type to "none" and "don't copy to output folder" for the DLL in your project.)

    PS: I use a German Visual Studio, so the captions I quoted may not exactly match the English version...

    0 讨论(0)
  • 2020-12-13 19:58

    In the right hand column under your solution explorer, you can see next to the reference to "Science" its marked as a warning. Either that means it cant find it, or its objecting to it for some other reason. While this is the case and your code requires it (and its not just in the references list) it wont compile.

    Please post the warning message, we can try help you further.

    0 讨论(0)
  • 2020-12-13 20:04

    Have you added the dll into your project references list? If not right click on the project "References" folder and selecet "Add Reference" then use browse to locate your science.dll, select it and click ok.

    edit

    I can't see the image of your VS instance that some people are referring to and I note that you now say that it works in Net4.0 and VS2010.

    VS2008 projects support NET 3.5 by default. I expect that is the problem as your DLL may be NET 4.0 compliant but not NET 3.5.

    0 讨论(0)
提交回复
热议问题