1

I'm building a Keygenerator application with .Net Maui (not blazor).

For this i use c#-Code in the MainPage.xaml.cs that calls a cpp .dll file and imports some methods.

The import looks like this:

    [DllImport("W5R._Keygen.dll", CallingConvention = CallingConvention.StdCall)]
    internal unsafe static extern void
    SHA256_calc(byte* hash, void* input, ulong inputlen);

The .dll is in the same folder as the MainPage.xaml, App.xaml etc.

By changing some properties of the .dll (Build = content) the Debug version on the Windows Machine works fine and it works exactly as it should.

HOWEVER: and this is the problem:

when I run the application on the android-emulator it loads the app just fine and as soon as i press a button that invokes the usage of the .dll my App Crashes and it just stopped working.

Beforehand I had the error ".system dll not found" which i fail to reproduce in the current moment.

Anyone knows how I use the .dll library? It's cpp code that i cannot access.

Albert
  • 17
  • 5
  • Does the dll you import from has its own dependencies that need to be deployed? If not is it compiled for the correct plattform? I assume the Android Emulator emulates an ARM plattform. – Ralf Sep 12 '22 at 12:56
  • Since it works perfectly as it's supposed to, when I start debugging under "Windows machine" I think that the dll file is not missing andy dependencies. I have not tested for Mac since I am missing the necessary emulation tools but my problem is that the android emulator cannot seem to handle the .dll file properly and i cannot find a way or instruction how to actually do that with having only the .dll at hand and not the source code – Albert Sep 12 '22 at 12:58
  • If it needs for example (just an example) the Visual Studio c++ runtime it will find it automatically on a development machine. A development machine is never a good test for the "is my deployment complete" question. – Ralf Sep 12 '22 at 13:00
  • Did I understand that correctly - My .dll might use other .dll under Windows and thats why it runs properly and as soon as i start it on an android emulator the .dll might call another .dll that is missing since its not the windows machine? – Albert Sep 12 '22 at 13:03
  • Yes that might be. If thats is needed the dll should have something about its deployment in its documentation. – Ralf Sep 12 '22 at 13:14
  • 2
    To the best of my knowledge DLL's only run on Windows. There are other ways of linking cpp code on android. – Palle Due Sep 12 '22 at 13:37

1 Answers1

1

You can't use a dll on Linux / Android. Dll are a windows thing and Linux has other formats for shared libraries.

see this Post

It seems there exists a wine release for Android, but I don't know how its used.

rxDietel
  • 66
  • 5