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

EnumerateSatelliteLibrarySearchPaths bug #148

Closed
FJGR65 opened this issue Dec 28, 2024 · 0 comments
Closed

EnumerateSatelliteLibrarySearchPaths bug #148

FJGR65 opened this issue Dec 28, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@FJGR65
Copy link

FJGR65 commented Dec 28, 2024

When the library is embedded as a resource, the EnumerateSatelliteLibrarySearchPaths method throws an exception.

This is because in the code

var runtimeAssembly = Assembly.GetExecutingAssembly();
string managedLocation = Path.GetDirectoryName(runtimeAssembly.Location) ?? AppDomain.CurrentDomain.BaseDirectory;

runtimeAssembly.Location is empty ("" => not null), and then Path.GetDirectoryName throw this excepcion:

"InnerException": {
"$type": "System.TypeInitializationException, mscorlib",
"TypeName": "ScintillaNET.Scintilla",
"Message": "The type initializer for 'ScintillaNET.Scintilla' threw an exception.",
"Data": {
"$type": "System.Collections.ListDictionaryInternal, mscorlib"
},
"InnerException": {
"$id": "2",
"$type": "System.ArgumentException, mscorlib",
"Message": "The path is not of a legal form.",
"ParamName": null,
"Data": {
"$type": "System.Collections.ListDictionaryInternal, mscorlib"
},
"InnerException": null,
"StackTrace": " at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.InternalGetDirectoryName(String path)
at ScintillaNET.Scintilla.d__2.MoveNext()
at ScintillaNET.Scintilla..cctor()",
"HelpLink": null,
"Source": "mscorlib",
"HResult": -2147024809
},
"StackTrace": " at ScintillaNET.Scintilla..ctor()
at ScintillaNET.WPF.ScintillaWPF..ctor()",
"HelpLink": null,
"Source": "Scintilla.NET",
"HResult": -2146233036
}

I'm sorry I can't give an example because it's quite complex.

A possible solution is to change the code to the following:

var runtimeAssembly = Assembly.GetExecutingAssembly();
string managedLocation = string.IsNullOrWhiteSpace(entryPointAssembly.Location) ? AppDomain.CurrentDomain.BaseDirectory : Path.GetDirectoryName(runtimeAssembly.Location);

OR

var runtimeAssembly = Assembly.GetEntryAssembly();
string managedLocation = string.IsNullOrWhiteSpace(runtimeAssembly.Location) ? AppContext.BaseDirectory : (Path.GetDirectoryName(runtimeAssembly.Location) ?? AppDomain.CurrentDomain.BaseDirectory);

Desktop (please complete the following information):

  • OS: W11 23H2
  • Version Scintilla.NET: 5.6.4
  • .NET Framework: 4.8
@FJGR65 FJGR65 added the bug Something isn't working label Dec 28, 2024
@desjarlais desjarlais self-assigned this Dec 30, 2024
desjarlais added a commit that referenced this issue Jan 1, 2025
Fix #148: Exception when `Scintilla.NET.dll` is loaded from memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants