I need to use DocumentFormat.OpenXml.dll in my code. In the solution package, I included this external dll in the Additional Assemblies. It looks like this:

enter image description here

I also need to reference it, so that I can use its classes in the code. So I added a reference to the same file. But now, when I want to deploy my solution it shoots error with the message:

"SharePointProject" and "SharePointProject" contain a file that deploys to the same Package location: DocumentFormat.OpenXml.dll

I guess the problem is that I haven't referenced the dll from additional package assemblies list, but directly from the file, though I could be wrong here.

How do I make sure that the external assembly DocumentFormat.OpenXml.dll gets deployed with the solution and I can use its classes in my code? Thanks!

  • I removed the reference from project (not package) and commented the code which uses its classes, just to test the deployment without it. I still get the same error, which means that the edit in the additional assemblies for package are causing it. Any clues? Thanks! – Boris Dec 27 '12 at 13:42
  • Have you copied or changed the location of any item in your solution? – user3470 Dec 27 '12 at 13:53
  • No, I am aware of that issue. If I remove the additional assembly from package, the solution deploys just fine. This leads me to a conclusion that the issue is related to adding external assemblies to the package. – Boris Dec 27 '12 at 14:06
  • Ensure 'Copy Local' is set to false in your assembly's reference. – James Love Dec 27 '12 at 14:07
  • Did you set the flag "specific Version" to false. This error comes up if you want to deploy two different versions of one assembly. – Sascha May 22 '14 at 17:48

I was facing the same issue recently. To solve this, I just removed the entries in 'Safe Controls' and 'Class Resources' section and saved 'Edit Existing Assembly' form. Then, it got deployed without issue.

  • +1, I also had a solution I needed to include OpenXML.dll with. I installed the SDK on my dev machine. In my project, I referenced the dll that had been installed in the GAC (by the SDK), but in my package, I added an existing assembly (with a source path of ..\..\..\..\..\..\..\Program Files (x86)\Open XML SDK\V2.0\lib\DocumentFormat.OpenXml.dll, the path of the dll in the SDK package but outside the GAC), and I did not put anything in the 'Safe Controls' or 'Class Resources' sections. Packages and deploys fine like that. – Dylan Cristy Aug 5 '15 at 17:41

Your problem may be related to incorrect locations of SharePoint Project Items (SPI). After you add your assembly click on Show All Files in the Solution Explorer in Visual Studio and locate the SharePointProjectItem.spdata file. Open it and make sure that the Target attribute of all the ProjectItemFileSource elements points to the correct location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.