Author Topic: System.DllNotFoundException error for 'Mobile App (Xamarin.Forms)' project  (Read 1017 times)

afsanchez001

  • Posts: 112
Hi,

I created a 'Mobile App (Xamarin.Forms)' project to use the Bass library. And I am referencing the 'Bass.Net.Android.dll' library in the Android project area (not the parent area).

The good news is that my class file lets me access all the methods from the Bass library.

However, when I run it I get this error at line 2 of my code: "System.DllNotFoundException: 'bass assembly:<unknown assembly> type:<unknown type> member:(null)'"

line 1:  BassNet.Registration("***", "***"); <-- Good.
line 2:  Bass.BASS_GetVersion();   <-- Error happens here.

I was hoping to find a Xamarin.Forms example online just to see if I am setting up my project correctly, but I cannot locate one.

So, are there further requirements aside from referencing the 'Bass.Net.Android.dll' library?

What is very curious, is that all the code I wrote i.e.(to stream Shoutcast, play MP3s, etc.) shows no error referencing the DLL methods, as they are all present.

But. I cannot get past that first step. Any ideas?

Thanks,
Anthony

radio42

  • Posts: 4737
looks, like the native bass.dll could not be found?!

afsanchez001

  • Posts: 112
I placed the native bass.dll file in the output folder for the main project.

In my solution configuration I have it output to the Debug folder.

     C:\source\repos\BassDllDemo\bin\Debug    <--- This is where the native bass.dll sits, in the "bin\debug\" output area.
     C:\source\repos\BassDllDemo.Android        <--- The Android project References "Bass.Net.Android.dll"
     C:\source\repos\BassDllDemo.iOS              <--- The iOS project References "Bass.Net.iOS.dll"

My project's .dll outputs to both: C:\source\repos\BassDllDemo\bin\Debug\netstandard2.0 & C:\source\repos\BassDllDemo\bin\Debug\netstandard2.0\ref

So to be safe, I placed the native bass.dll (BASS module) from the root of the bass24.zip in the two paths.

What I am not certain of, is if I need to use the x64 BASS module rather than the x86? My project's Platform Target is set to "Any CPU". And so I did try both, separately, but each one still producing the same error.

I don't want to give up on this. I know I am close.

afsanchez001

  • Posts: 112
Please forgive me, but I am a total newbie to Xamarin/Android/iOS.

With that being said...  ;D

In my C# WinForms code I am able to point to the x86 and x64 folder accordingly using a target path.

Code: [Select]
TargetPath = Path.Combine(programDataWindowsApplication.ToString(), Utily.Is64Bit ? @"_bass\x64" : @"_bass\x86");
Then I simply do,
Code: [Select]
Bass.LoadMe(TargetPath) and it works just fine.

But
Code: [Select]
LoadMe() is not showing up in the Bass.* methods in my Xamarin project.

So I am not sure if this means anything.


radio42

  • Posts: 4737
The LoadMe methods use internally a kernal32.dll reference funtion to manually load a library. This is on Android of course not supported.
But not needed, as with the call to a BASS function the lib is loaded automatically anyhow.

afsanchez001

  • Posts: 112
Got it.

Thanks for the help understanding that.

So I decided to try another approach to resolve the native bass.dll problem. I found another BASS forums post (https://www.un4seen.com/forum/?topic=16365.msg125236#msg125236). And I did what it proposed.

1) I copied the "\libs" folder from bass24-android onto the root of the project folder.
2) I added Java.Lang.JavaSystem.LoadLibrary("bass"); to the MainActivity.cs file in the OnCreate() method.
3) I edited the AppName.Android.csproj <ItemGroup> for AndroidNativeLibrary & ABI.

But...

4) I removed the native bass.dll file from the output folder "bin\debug". Because the program is now using the "libbass.so".

IT WORKED. The program now gets beyond the original error, and it gets to the rest of my code.

Thanks!
« Last Edit: 19 Mar '21 - 15:45 by afsanchez001 »

radio42

  • Posts: 4737
Yes, that is the related native bass lib for Android ;-)

Nefsky

  • Posts: 6
I have the same problem. I connected the Bass.Net.dll library to Xamarin.Forms by adding a link and I also get an error when running on the emulator "System.DllNotFoundException: 'bass assembly: <unknown assembly> type: <unknown type> member: (null)' ".

serkanp

  • Posts: 112
on android and linux, they use .so files respective to platform.
on windows , depending on x86/x64 you will use bass.dll
on android, there are 4 platforms related.. arm64-v8a, armeabi-v7a, x86, x86_64 and there are bass.so components
so on each platform, xamarin forms decides which one it will use..
you must add all 4 android platform depended folders and *.so files (libbassmix.so, libbassenc.so, libbass.so etc)

Nefsky

  • Posts: 6
serkanp, understood thanks.