简体   繁体   English

在Visual Studio 2010中未加载参考DLL

[英]Reference DLLs not loading in Visual Studio 2010

I'm working on a C# 4.0 project in VS2010 and needed to use some older DLLs containing controls that were created in C# 3.5 on VS2008. 我正在VS2010中从事C#4.0项目,需要使用一些较旧的DLL,其中包含在VS2008上C#3.5中创建的控件。 When I first add the DLLs to the references, I was able to see the namespace via intellisense and create an instance of one of the controls, but when I go to build, it gives me the following error: 当我第一次将DLL添加到引用中时,我能够通过intellisense看到名称空间并创建控件之一的实例,但是当我进行构建时,它给了我以下错误:

The type or namespace name 'BCA' could not be found (are you missing a using directive or an assembly reference?)

And I do have a using directive for that namespace already, which is now underlined in red, showing that VS cannot find it. 而且我确实已经对该名称空间使用了using指令,该指令现在用红色下划线标出,表明VS无法找到它。 And now, intellisense won't pick up that namespace at all. 现在,intellisense根本不会选择该名称空间。

I even tried added the controls to the toolbox (which worked) but then when I drag them to the GUI, it says that it cannot locate the DLL reference, even though it obviously knows where it is. 我什至尝试将控件添加到工具箱(可以工作),但是当我将它们拖到GUI时,它说它无法找到DLL引用,即使它显然知道它在哪里。

I even tried changing the target framework to 3.5, but still with the same results. 我什至尝试将目标框架更改为3.5,但结果仍然相同。

Any thoughts as to why this could be happening? 关于为什么会发生这种情况的任何想法?

Edit - I've notice that in the csc.exe arguments that VS outputs, it does not have any /reference entries for the DLLs I'm trying to use. 编辑 -我注意到,在VS输出的​​csc.exe参数中,它没有我要使用的DLL的任何/ reference条目。 When I create the same basic project in VS2008, those entries exist. 当我在VS2008中创建相同的基本项目时,这些条目存在。 Also, I can successfully reference the DLLs in a DLL project in VS2010... it seems to just be WinForms projects that don't work. 另外,我可以在VS2010的DLL项目中成功引用DLL……似乎只是WinForms项目不起作用。

Turns out that it was something to do with VS2010 defaulting to the .NET 4 client profile , as soon as I changed it to the regular profile it built fine. 事实证明,这与VS2010默认为.NET 4 客户端配置文件有关 ,一旦我将其更改为常规配置文件,它就可以正常运行了。 There's a day wasted... 浪费了一天...

查看目标框架..在我的项目中,是4.0客户端配置文件,e参考dll在4.0中

我尝试了Build-> Clean Solution,然后可以添加引用。

I used to have similar problem, but the profiles were not the issue, so the problem was that my class library use a special NuGet package that has Dependency... so I install the dependency package in the target project and added the project reference and works! 我曾经遇到过类似的问题,但是配置文件不是问题,所以问题是我的类库使用了一个特殊的具有依赖关系的NuGet包...因此我将依赖包安装在目标项目中,并添加了项目引用和作品!

But I am not sure if there is a better solution for this problem??? 但是我不确定这个问题是否有更好的解决方案??? for me VS should be smart enough to carry those dlls along with the references. 对我来说,VS应该足够聪明,可以随身携带这些dll和参考文件。 (I already verified that "Copy Local" is set to True) (我已经确认“复制本地”设置为True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM