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:
build.open-xml-sdk.sh
, but it returned an error. Please see my OP... – Infer