SharePoint 2010 Development : Getting Error Cannot Add Reference to "Microsoft.SharePoint.Publishing.dll” and a fix
Recently , I stumbled into a issue while adding a reference to “Microsoft.SharePoint.Publishing.dll” assembly in my windows console application project . I was using Visual Studio 2010 Beta 2 and the project target framework is set to “3.5” (which is requirement for all SharePoint 2010 projects along with platform setting to x64)., and I am running SharePoint Server 2010 in standalone mode , on Windows Server 2008 R2.
[All screen shots are of high quality , you may need to click on them to see the clear image]
So , following is the screen shot of the error that I received.
**“Microsoft.SharePoint.Publishing.dll or one of its dependencies requires a latest version of .NET Framework than one specified in the project”
**
What surprises me, is that I can add references to assemblies like “Microsoft.SharePoint.dll’ and “Microsoft.SharePoint.Clinet.dll” to the project without any hassle. I finally got the fix from SharePoint MSDN forum where I posted this as a question , Paul Andrew point out that this is because in some cases (like in mine) , certain assemblies have dependency on an incorrect version of “System.Web.DataVisualization” assembly. So the fix is to simply add a reference to the correct version of “System.Web.DataVisualization” assembly. He mentioned fix this will be published in a FAQ which will be available soon. Read the thread here.
In case you are facing the same issue , you can use the steps below , I have used the screen shots to make it bit easier. The fix worked in Visual Studio 2010 Beta 2 , but I think it should also work with Visual Studio 2005/2008 ,but as I did not test it yet in those versions I cannot say for sure.
1. In your Visual Studio project , right click “Add References” and select “Add Reference”
2. You need to add a reference to “System.Web.DataVisualization” assembly. Which is located at “
Now once you located the assembly path , you can provide it inside the “Add Reference” dialog and select “System.Web.DataVisualization.dll” , click “OK”.
You should now see the assembly ““System.Web.DataVisualization” along with other assemblies.
3. Now , right click “Add References” and select “Add Reference” , this time you will be adding “Microsoft.SharePoint.Publishing.dll” . This assembly is located at
“
Once you know the path , use it to add reference to “Microsoft.SharePoint.Publishing.dll”. Cick “OK” , you might see the dialog with the original error message , just ignore it and click “Yes” . See the screen shot below.
You should now able to use “Microsoft.SharePoint.Publishing” assembly with all its classes and methods without any issues.
I had compiled and test the codes and they are working fine. Following are the two screen shots of a simple code using the Publishing assembly.
Compile successful without issues
Code executes without any issues
Cheers
Razi
Originally published on WordPress on 2009-11-24.
Read next
-
MVP SharePoint Chat — Wednesday May 25th at 9am PDT
When: 9 AM PDT, 25th May 2011 (PDT? Convert to your time zone here) Where: Online | Enter Chat Room Do you have tough technical questions regarding SharePoint for which you're seeking answers? Do…
-
How to fix SharePoint Online (403) Forbidden Error while downloading files using Client Object Model
Recently I was working on a project that requires to programmatically access and download files from SharePoint Online (part of Office 365) document library. Currently remote authentication (SP…
-
Office 365 Session @ Microsoft NYC
As Office 365 goes into public beta, it's time to dig deeper into the features of Office 365. I am conducing a session on Office 365 with demo of its services @ Microsoft NYC on 27th April 2010…
Worth reading again?
Get the next one in your inbox.







