Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

c# - Visual Studio refuses to build project due to missing assembly reference that isn't missing

I'm building a c# windows service and has added a couple of assembly references (to other projects of my own) to my project.

I get the following error when I build:

"Error 25 The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?"

Interestingly enough, the reference path in the csproj-file is correct, and on top of that, classes and namespaces from the referenced project, that according to Visual Studio is missing, is being picked up by Intellisense and even the "go to definition" function works fine. Furthermore, I have other projects in the exact same folder as my new windows service and they picked up the assembly references just fine. All the referenced projects are included in the solution.

I use Visual Studio 2013 Update 3. There is really no code that I could show that would give you more information, but let me know if you want to see some screenshots or something.

Attempts so far:

Update When I select one of the "missing" references in the reference list, and go to properties, there is no path defined. Yet, the relative path is in the csproj-file as is correct. Confusing.

Update 2 Removing all the references, reloading the projects and then doing a clean fixed it for me. Apparently, the problem was caused by all dlls not being updated in the build stack.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In my case, target Framework of Assembly Project and the target Framework of the project where i want to use this assembly are different. Target framework of assembly project was 4.5 and target framework of my project was 4.0.

When I have change the target framework of my project to the target framework of assembly project i.e. from 4.0 to 4.5 , it works fine.

For change the Target Framework of project,

Right Click the project -> Properties -> Application -> Target Framework

This Target Framework is drop-down list, select your required Framework from this list.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...