I am trying to migrate to 3.8 (new project) and am running into a runtime error DllNotFoundException ‘Unable to load ‘steam_api’ or one of its dependencies.’
I suspect that this is because the libsteam_api native reference that Steamworks.Net requires has not been included in my project but i can’t for the life of me figure out how to add a native reference to this project. The option just isn’t there.
Can anyone help? Is it because the new MacOS templates target .Net Core?
I know nothing about the api but this is some of the problems i encounterd moving over to 3.8 one of witch is a DllNotFoundExeption maybe it will help.
Thanks for the replies. Yes, I’ve consulted the docs (I have this working fine in 3.6).
The issue is not that the dll isn’t found but that the .dylib the .dll depends on is not there. It’s a runtime error rather than a build error.
After fiddling around a bit I have tried copying it manually to the same location as other .dylib files and, somewhat to my surprise, this works! I can’t find a way to add the .dylib to the project though as there is no ‘add native reference’ option as there is in my 3.6 project.
There’s probably another way to just get it to copy the file at build time so I’ll look into that.
Create a folder structure in your project that mirrors that of the runtimes folder in the output directory, i.e…
runtimes/osx/native
Add the libsteam_api.dylib to your project at runtimes.osx/native/libsteam_api.dylib. It can be a linked reference, doesn’t matter, as long as the folder structure within your project is correct.
Open your .csproj file with a text editor and search for libsteam_api. There should be a reference to it something like this…
This should copy the native library to the correct place. I haven’t tried with the other supported CPDA platforms but I’m guessing that following that same procedure but using the appropriate source file and destination location for each platform should work.
The solution above works when running from Visual Studio. However, I have since discovered that that folder structure doesn’t work if you publish as a self contained app using dotnet publish. In this instance it does work if you put the .dylib at the root level along with all the other .dlls. Unfortunately this has the downside that your cross-platform project is no longer cross platform as there can only be one .dylib with that name at the root level.
So, partially solved but I don’t yet have a solution that will work when publishing cross-platform from the same project.