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

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/23654

Question

I have a weird problem I just can't place.

I have a SP 2010 project which contains two sub-projects of type class library (FirstLib and SecondLib).

The project build fine, no errors whatsoever, but once I deploy to the server I get errors in VisualStudio's "Error List" window:

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

The type X is in FirstLib and is referenced from SecondLib. In the package manifest I specified that both be deployed to GAC and I can see they are there, but I still see that message, and I get it for every type in FirstLib that is used by SecondLib.

What's even weirder is that in the "Output" window I see this.

========== Build: 3 succeeded or up-to-date, 0 failed, 0 skipped ========== ========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

What could be the cause for this?

What should I check further?

Was it helpful?

Solution

I get this exact problem myself. I can't work it out either, but I have noticed that it will only occur when I have certain source code files open and active in Visual Studio (in your case it would be a code file from the SecondLib project), and it would only occur when trying to do a package or deploy action.

If you close the source files from SecondLib before doing a deploy the errors should go away.

OTHER TIPS

I had the same problem. (Re-)Built successful but deployment to SharePoint and manually packaging (Visual Studio -> Pubish) failed. I solved the problem by switching "Copy-Local" to false in every project (about 15 Class Library projects and three SharePoint Projects).

I think the problem is the linking between each project so Visual Studio can not resolve the dependencies in the right way.

Make sure you've added other projects to main package. See http://www.sharemuch.com/2010/03/17/deploying-referenced-assemblies-with-your-vs2010-sharepoint-2010-wsp-solution/

Also you can open in Windows Exploerer - C:\Windows\Assembly and make sure your referenced dlls are deployed to GAC.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top