Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DocumentFormat.OpenXml in Ubuntu server

I have a basic C# application where Open XML SDK is used. I want to make it run in my Nginx & Ubuntu & DigitalOcean server.

The application compiles and works well in Windows, and my Mac with mono. Then, I installed mono in the Ubuntu server, and scp the .exe file to the server, and run mono ConsoleApplication2.exe, it returned the following error:

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
File name: 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 at ConsoleApplication2.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
File name: 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
  at ConsoleApplication2.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

I have found this link, it seems that the problem comes from the version of DocumentFormat.OpenXml. But how could I install its right version in a Ubuntu server?

Could anyone help?

Update 1: Then, I tried to install Open XML SDK 2.6.1, but there is no makefile. Otherwise, for Open XML SDK 2.5, I don't know where to find a release distribution.

Update 2: I should have tried build.open-xml-sdk.sh... I tried to run it in the server, but it gives an error. Does anyone know what's wrong here?

Update 3: I uninstalled mono, and followed this link:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mono-complete

mono was re-installed successfully. Then I tried build.open-xml-sdk.sh again, but it returned the same error.

Update 4: Following the comment of ZagNut, I tried to add DLLs to GAC. I noticed two things:

1) I downloaded the source code and generated DocumentFormat.OpenXml.dll and System.IO.Packaging.dll, they made my program compile well in Visual Studio. However, when i tried to add them to GAC by gacutil, it tells me they need a strong name.

2) Then I tried to add strong name to them by following this page, I realised that the new 2 dlls could not work correctly in Visual Studio anymore:

enter image description here

like image 502
SoftTimur Avatar asked Sep 12 '16 03:09

SoftTimur


People also ask

Does OpenXML work on Linux?

LibreOffice has built-in support for reading and writing Office Open XML files. It is available for Windows, macOS, Linux, etc. Microsoft Office 2007, Microsoft Office 2010, and Microsoft Office 2013 for Windows use the Office Open XML format as the default.

How do I add DocumentFormat OpenXML reference?

Go to your Solution Explorer > right click on references and then click Manage NuGet Packages . Then search in tab "Online" for DocumentFormat. OpenXml and install it. After you can use DocumentFormat.

Is DocumentFormat OpenXML free?

documentformat. openxml. dll free download | DLL‑files.com.

What is run in OpenXML?

A run is represented by an r element, which allows the producer to combine breaks, styles, or formatting properties, applying the same information to all the parts of the run. Just as a paragraph can have properties, so too can a run.


1 Answers

just put the binaries you need alongside your application executable.

for the binaries, you can build it yourself: https://github.com/OfficeDev/Open-XML-SDK

or download from below and just extract the binaries using Universal Extractor or installing it and finding them.

2.0: https://www.microsoft.com/en-us/download/details.aspx?id=5124

2.5: https://www.microsoft.com/en-us/download/details.aspx?id=30425

like image 115
ZagNut Avatar answered Nov 21 '22 11:11

ZagNut