How to include the reference of DocumentFormat.OpenXml.dll on Mono2.10?
Asked Answered
C

10

33

I am using C#.net Windows Desktop Application.I want to run these application with other platform also. So, i am using Mono 2.10 as a cross compiler.While running,unexpectedly my Application is terminated by saying the error message like

Error:Could not open the selected folder.
Could not load a file or assembly 'DocumentFormat.OpenXml.dll,version=2.0.5022.0, culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

I don't know what is problem here...I have installed openxml sdk2.0 on c:\program files\open xml sdk\v2\lib\DocumentFormat.OpenXml.dll.

and also put my application eXe on on the same place for testing purpose...

Please guide me to solve this issue...

Carolyncarolyne answered 10/3, 2011 at 10:29 Comment(0)
T
21

You should also ensure you set a reference to WindowsBase. This is required to use the SDK as it handles System.IO.Packaging (which is used for unzipping and opening the compressed .docx/.xlsx/.pptx as an OPC document).

Tecumseh answered 10/3, 2011 at 17:31 Comment(4)
i have set a reference of the WindowsBase in C#.Net(4.0) through project explorer window.But till i am not able to solve that issue...what i do next?Carolyncarolyne
if you have more projects than one within solution try to include to others too. may be you are including to wrong oneDisconnection
Thanks. I didn't have System.IO.Packaging specifiedEgotism
This is weird that user is getting run time error. The moment you start trying to use classes like SpreadsheetDocument in cod the compiler itself starts giving error. On run-time it should pick WindowsBase.dll from Global Assembly Cache (GAC) of .Net Framework.Plummer
S
22

Being new to this myself, here's what I did:

I'm using MS Visual Studio 2010 Pro.

  1. Download and install the OpenXML SDK
  2. Within my project in Visual Studio, select "Project" then "Add Reference"
  3. Select the "Browse" tab
  4. In the "Look in:" pull down, navigate to: C:\Program Files(x86)\Open XML SDK\V2.0\lib and select the "DocumentFormat.OpenXml.dll
  5. Hit OK
  6. In the "Solution Explorer" (on the right for me), the "References" folder now shows the DocumentFormat.OpenXML library.
  7. Right-click on it and select Properties
  8. In the Properties panel, change "Copy Local" to "True".

You should be off and running now using the DocumentFormat classes.

Spatola answered 3/6, 2014 at 22:25 Comment(0)
T
21

You should also ensure you set a reference to WindowsBase. This is required to use the SDK as it handles System.IO.Packaging (which is used for unzipping and opening the compressed .docx/.xlsx/.pptx as an OPC document).

Tecumseh answered 10/3, 2011 at 17:31 Comment(4)
i have set a reference of the WindowsBase in C#.Net(4.0) through project explorer window.But till i am not able to solve that issue...what i do next?Carolyncarolyne
if you have more projects than one within solution try to include to others too. may be you are including to wrong oneDisconnection
Thanks. I didn't have System.IO.Packaging specifiedEgotism
This is weird that user is getting run time error. The moment you start trying to use classes like SpreadsheetDocument in cod the compiler itself starts giving error. On run-time it should pick WindowsBase.dll from Global Assembly Cache (GAC) of .Net Framework.Plummer
S
7

select DocumentFormat.OpenXml under references , view it's properties, and set the Copy Local option to True so that it copies it to the output folder. That worked for me.

Situated answered 6/8, 2013 at 20:58 Comment(0)
A
7

Goto Nuget Package manager and search for openxml. And install DocumentFormat.OpenXml

A answered 5/1, 2016 at 5:44 Comment(0)
N
3

What worked for me:

  1. Add a folder to the project call it ThirdParty.
  2. Add in the ThirdParty folder both DocumentFormat.OpenXML.dll and WindowsBase.dll
  3. Make sure the the project uses the ThirdParty dir as reference for both the DLLs
  4. Build and published to an external server.
Notus answered 8/6, 2015 at 6:56 Comment(0)
L
1

Well, In my applications I just need to Add a reference to "DocumentFormat.OpenXml" under .Net tab and both references (DocumentFormat.OpenXml and WindowsBase) are always added automatically. But They are not included within the Bin folder. So when the Application is published to an external server I always place DocumentFormat.OpenXml.dll under the Bin folder manually. Or set the reference "Copy Local" property to true.

Leviticus answered 3/3, 2014 at 16:40 Comment(1)
I have used this solution successfully in VisualStudio 2017 with Website projects. At present, I copy the .net reference assembly from <system drive>\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\<.net version desired>\<dllname>.dll to my website's /bin folder.Baese
I
0

You need to have DocumentFormat.OpenXML.dll in the same folder as your application - or in the 'bin' path if you are developing an ASP.NET application. However, I'm not certain that the OpenXML SDK is supported on non-Windows operating systems - you may need to look into a third-party solution.

Yes, this answer is right, the only difference is that you copy your .dll into bin folder of the project.

Itching answered 22/1, 2013 at 16:1 Comment(0)
A
0

After viewing and changed the properties to DocumentFormat.OpenXml, I also had to change the Specific Version to false.

Andersonandert answered 24/9, 2014 at 16:18 Comment(0)
D
0

I found that when mixed with PCL libraries the above problem presented itself, and whilst it is true that the WindowsBase library contains System.IO.Packaging I was using the OpenXMLSDK-MOT 2.6.0.0 library which itself provides it's own copy of the physical System.IO.Packaging library. The reference that was missing for me could be found as follows in the csharp project

<Reference Include="System.IO.Packaging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\..\..\packages\OpenXMLSDK-MOT.2.6.0.0\lib\System.IO.Packaging.dll</HintPath>
  <Private>True</Private>
</Reference>

I downgraded my version of the XMLSDK to 2.6 which then seemed to fix this problem up for me. But you can see there is a physical assembly System.IO.Packaging.dll

Damper answered 23/12, 2016 at 18:0 Comment(0)
T
0

The issue for me was that DocumentFormat.OpenXml.dll existed in the Global Assembly Cache (GAC) on my Win7 development box. So when publishing my project in VS2013, it found the file in the GAC and therefore omitted it from being copied to the publish folder.

Solution: remove the DLL from the GAC.

  1. Open the GAC root in Windows Explorer (Win7: %windir%\Microsoft.NET\assembly)
  2. Search for OpenXml
  3. Delete any appropriate folders (or to be safe, cut them out to your desktop in case you should want to restore them)

There may be a more proper way to remove a GAC file (below), but that is what I did and it worked. gacutil –u DocumentFormat.OpenXml.dll

Hope that helps!

Triform answered 13/3, 2018 at 14:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.