Blake Regalia
Blake Regalia

Reputation: 2766

Running C# Binary on Linux using mono-devel

I have the following two files in a directory on Ubuntu:

program.exe
RFIDAPI.dll

program.exe was compiled on a Windows 7 machine using Visual C# Express as a "Console Application"

RFIDAPI.dll is a library that was given to me by the company who implemented the API for communicating with their device over ethernet.

When I run ./program.exe on the Ubuntu machine, mono-devel fails to find the dynamic library:

Unhandled Exception: System.DllNotFoundException: RFIDAPI.dll
    at(wrapper managed-to-native) Namespace.RFID_Class:Method_Call ()

The program runs fine on Windows with the same conditions. Any idea how I can get this program to link to the DLL on Ubuntu using mono-devel?

Upvotes: 0

Views: 1300

Answers (2)

Blake Regalia
Blake Regalia

Reputation: 2766

A simple debugging helps point out the problem

export MONO_LOG_LEVEL=debug
./program.exe
...

This page has all the information I was looking for: http://www.mono-project.com/DllNotFoundException

Upvotes: 1

Corey
Corey

Reputation: 16564

The only viable solution is to ask the company who supplied the DLL if they have a Linux library suitable for your particular distribution (Ubuntu version and Linux kernel version) that you can link against.

Each platform has different ways of handling native code libraries, and these libraries are not compatible between platforms. It is therefore not possible to link against a platform-specific library (a Windows DLL for instance) in a platform-neutral fashion.

MONO is a cross-platform re-implementation of the .NET runtime. It is intended to provide the ability to write .NET applications for non-Windows operating systems, and provides a reasonably consistent framework to enable you to easily port existing .NET applications. It is not a Windows emulator so it cannot use Windows-specific code, which includes any Windows-specific libraries.

Upvotes: 0

Related Questions