简体   繁体   中英

VS2010 does not find current context yet the reference is built

I'm building an application using Visual Studio 2010 in which I have to use an external dll. While I'm coding, the IDE is not showing to me any errors about methods owned by this dll I added to my project. I can even browse the class object hierarchy. Once I try to compile my project, this reference is lost. I can't browse the reference anymore and I'm getting the usual error "does not exists in the current context". I've even recompiled the dll but I'm still having this error.

In your Project's properties, click on the "Application" tab. Check and see what the "Target Framework" is set to. I was encountering something similar to this before and it was all because the Target Framework was set to ".NET Framework 4 Client Profile" instead of ".NET Framework 4."

Edit

I'm not exactly sure why this solved the issue in my case with missing references, but it did work. I was following the recommendation of another SO link that I'll add if I can find again.

you will get this error if

Your DLL project targeting different .NET Framework version than your project who uses this DLL

so make sure that your Referenced Project (DLL Provider) is using the same version of .NET Framework that your other project (DLL consumer) uses

Try to check whether Visual Studio has set the Path to your dll correctly:

Right-click the dll and go to Properties. Then in the properties window you have one line stating the physical path to the dll.

I sometimes had the problem that this line was empty and therefor the dll was marked with a yellow questionmark.

If the line is empty filling in the correct path to your dll my solve your problem.

hope that helps, cheers

It could be an issue with the platform your project is targeting and the platform of the dll. Try specifying explicitly x86 or 64 and see what happens. If it work, then check if you are happy with that platform or if you will need to find the dll compiled for the other or if you will need to find another library.

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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