Reference DLLs not loading in Visual Studio 2010

2019-01-26 07:01发布

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. 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:

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. And now, intellisense won't pick up that namespace at all.

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.

I even tried changing the target framework to 3.5, but still with the same results.

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. When I create the same basic project in VS2008, those entries exist. Also, I can successfully reference the DLLs in a DLL project in VS2010... it seems to just be WinForms projects that don't work.

4条回答
我命由我不由天
2楼-- · 2019-01-26 07:37

I tried Build->Clean Solution and then could add the reference.

查看更多
劫难
3楼-- · 2019-01-26 07:38

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!

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. (I already verified that "Copy Local" is set to True)

查看更多
再贱就再见
4楼-- · 2019-01-26 07:42

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. There's a day wasted...

查看更多
我命由我不由天
5楼-- · 2019-01-26 07:42

view the target framework.. in my project, was 4.0 client profile, e the reference dll was in 4.0

查看更多
登录 后发表回答