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

realm-wrappers.dll cannot be found in a single file application #3483

Closed
A9G-Data-Droid opened this issue Nov 22, 2023 · 3 comments
Closed

Comments

@A9G-Data-Droid
Copy link

What happened?

When publishing as a single file in net6+ Realm cannot find the realm-wrappers.dll file. I can see other similar issues but nobody specifically talking about PublishSingleFile.

The workaround is to copy realm-wrappers.dll around with the exe but now it's not a single file. It's two files, which is double the number of files expected.

Repro steps

  1. Add <PublishSingleFile>true</PublishSingleFile> to your .csproj
  2. Now the realm-wrappers.dll cannot be found

Version

net8.0-windows

What Atlas Services are you using?

Local Database only

What type of application is this?

Console/Server

Client OS and version

Windows 10 Pro 22H2

Code snippets

true

Stacktrace of the exception/crash you're getting

The type initializer for 'Realms.SharedRealmHandle' threw an exception.

Relevant log output

No response

@nirinchev
Copy link
Member

Do you have a repro project? I tried this in a .net 8 console app and it works as expected. Here's the command I use to build: dotnet publish -c Release -r win-arm64 -p:IncludeNativeLibrariesForSelfExtract=true and here's the csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishSingleFile>true</PublishSingleFile>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Realm" Version="11.6.1" />
  </ItemGroup>
</Project>

@nirinchev nirinchev self-assigned this Nov 23, 2023
@A9G-Data-Droid
Copy link
Author

Your reply has the answer in it.

To my FolderProfile.pubxml file I added:

<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>

And now it is working. I apologize, is this documented somewhere? because I didn't see it.

@nirinchev
Copy link
Member

It's not something particularly special about Realm - it's a configuration option you need for any library that comes with native dependencies, though I understand if it's not obvious that Realm has native dependencies. We'll try to see where it fits in the documentation as it's somewhat niche but would be useful to document anyway.

@nirinchev nirinchev closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants