Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Mono to load and access simple DLL in Ubuntu #21743

Open
jokubas11 opened this issue Jan 31, 2024 · 1 comment
Open

Using Mono to load and access simple DLL in Ubuntu #21743

jokubas11 opened this issue Jan 31, 2024 · 1 comment

Comments

@jokubas11
Copy link

I am wondering if I am misunderstanding what Mono can do?

I am not a C# or .NET person, so bear with me. What I need is to be able to load an external (third-party) .DLL which was built to be used with .NET project (.NET 4.6 in particular).

The DLL File is: PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows

What I did in the Windows was very simple: I have opened Visual Studio, added reference to the file and that's it, I was able to import it with 'Using Driver.dll;' right away and use it.

Now, I need to do the same on my Ubuntu 22.04 OS. From what I understand, I should be able to do this using Mono. I have installed Mono, successfully ran Hello World application, but now, I am lost at how am I supposed to use Mono to import my DLL file.

I want to remind, I do not need to do anything complicated, I just want to load that DLL and call 1 method, and that is it.

  • I have installed Mono, and the Mono 'Compatibility' page says that it supports .NET 4.6, but how does it work exactly. When I run csc HelloWorld.cs, how will it know what to use and where.
  • How do I exactly import the DLL? I saw Dllmaps page, but it was not helpful for me, as I understand, it maps given DLL files to already existing .so libraries, and I do not have that and I do not know anything about the internals of the .DLL, besides the few methods it contains. I also tried to -r:Driver.dll during build, but I assume that is not it, as I am not able to use it in code:
System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.InvalidProgramException:

Please, could someone just point me to what should I do, if I want to just import one DLL and use its function in the same way I did very effortlessly in Visual Studio on Windows.

@andreygursky
Copy link

I just want to load that DLL and call 1 method, and that is it.

The code in [1] looks like a good minimal example. In [2] you can find details.

[1] https://stackoverflow.com/questions/22261841/mono-embedding-get-monoclass-without-knowing-the-namespace
[2] https://www.mono-project.com/docs/advanced/embedding/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants