Skip to content

fix: native support when using Mono on Windows - #2842

Merged
bitsandfoxes merged 10 commits into
mainfrom
fix/native-library-name-clash
Sep 14, 2026
Merged

bitsandfoxes merged 10 commits into
mainfrom
fix/native-library-name-clash

Conversation

@bitsandfoxes

Copy link
Copy Markdown
Contributor

Closes #2818, continues #2819

Native crash capture never worked on Windows with the Mono scripting backend. Mono probes the calling assembly's own folder first, so DllImport("sentry") from Sentry.Unity.Native.dll resolved to the managed Sentry.dll sitting beside it in Managed/ on a case-insensitive file system. That load succeeds, the C entry point is missing, and native support dies with an EntryPointNotFoundException that only surfaces when the diagnostic logger is enabled.

The desktop library now ships renamed. native-sdks.targets writes it out as sentry-native.dll, libsentry-native.so and libsentry-native.dylib while the SDK is built, so the package already carries the new names and the post-build step stays a plain copy. Debug sidecars keep the names their binaries record.

Android cannot follow. Its libsentry.so comes from the sentry-android-ndk AAR and sentry-java loads it by name from Java, so it gets its own Sentry.Unity.Native.Android.dll, built from the same sources with a define the way the console variants already are.

bitsandfoxes and others added 6 commits September 10, 2026 16:04
Native crash capture never worked on Windows with the Mono scripting
backend. Mono probes the calling assembly's own folder first, so
`DllImport("sentry")` from `Sentry.Unity.Native.dll` resolved to the
managed `Sentry.dll` sitting beside it in `Managed/` on a
case-insensitive file system. That load succeeds, the C entry point is
missing, and native support dies with an `EntryPointNotFoundException`
that only surfaces when the diagnostic logger is enabled.

The desktop library now ships renamed. `native-sdks.targets` writes it
out as `sentry-native.dll`, `libsentry-native.so` and
`libsentry-native.dylib` while the SDK is built, so the package already
carries the new names and the post-build step stays a plain copy. Debug
sidecars keep the names their binaries record.

Android cannot follow. Its `libsentry.so` comes from the
sentry-android-ndk AAR and sentry-java loads it by name from Java, so it
gets its own `Sentry.Unity.Native.Android.dll`, built from the same
sources with a define the way the console variants already are.

Closes #2818

Co-authored-by: Lou Garczynski <louis.roc@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A1tV2g8KkFQGYdCGLWSay6
Comment thread src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Comment thread package-dev/Plugins/Switch/SentryStub~/sentry_native_stubs.c

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 71f2f6e. Configure here.

Comment thread src/Sentry.Unity.Editor/Native/SwitchNativeStub.cs
@bitsandfoxes
bitsandfoxes merged commit 45d00c2 into main Sep 14, 2026
65 of 67 checks passed
@bitsandfoxes
bitsandfoxes deleted the fix/native-library-name-clash branch September 14, 2026 09:47
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

Successfully merging this pull request may close these issues.

crash report don't work on windows due to dll name conflict

2 participants