You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can confirm this works in all but one use case, and that's when there is a space in the path of the resolved executable. In that case, the spaces appear as %20 in the LoadLibraryW call which Windows is not happy about. This can happen, for example, when the resolved executable lives in Program Files.
The following example demonstrates this behavior (using native_add_app again):
$ dart --enable-experiment=native-assets build --output="native output" .\bin\native_add_app.dart
$ New-Item-Path .\native_add_app.exe-ItemType SymbolicLink -Value ".\native output\native_add_app.exe"
$ .\native_add_app.exe
Invoking a native function to calculate 1+2.
Unhandled exception:
Invalid argument(s): Couldn't resolve native function 'add' in 'package:native_add_library/native_add_library.dart' : Failed to load dynamic library 'lib\native_add_library.dll': Failed to load dynamic library 'c:/workspace/native/pkgs/native_assets_cli/example/build/native_add_app/native%20output/lib/native_add_library.dll': The specified module could not be found. (error code: 126).#0 Native._ffi_resolver.#ffiClosure0 (dart:ffi-patch/ffi_patch.dart)#1 Native._ffi_resolver_function (dart:ffi-patch/ffi_patch.dart:1523)#2 add (package:native_add_library/native_add_library.dart)#3 main (file:///c:/workspace/native/pkgs/native_assets_cli/example/build/native_add_app/bin/native_add_app.dart:9)#4 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297)#5 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184)
This is running against the current main:
Dart SDK version: 3.5.0-edge.09e87e6d7bd18e3b08cc96c3a42b8e3f37a096d6 (main) (Wed Jun 19 14:50:30 2024 +0000) on "windows_x64"
If there is a %20 then it's most likely because the path text was parsed as a URI, and not unparsed back to a system path.
The path using forward slashes together with a Windows drive name suggests the same thing.
Use File.fromUri(uri).path rather than uri.path. The latter can contain escaped characters, the former should be a valid file path, which may need to be quoted since it can contain spaces.
(If the path contained a %, or any URI delimiter character, that would probably be escaped too.)
If there is a %20 then it's most likely because the path text was parsed as a URI, and not unparsed back to a system path. The path using forward slashes together with a Windows drive name suggests the same thing.
Correct.
Use File.fromUri(uri).path rather than uri.path. The latter can contain escaped characters, the former should be a valid file path, which may need to be quoted since it can contain spaces. (If the path contained a %, or any URI delimiter character, that would probably be escaped too.)
The error was in the C++ code, but the same logic applies. 👍
I can confirm this works in all but one use case, and that's when there is a space in the path of the resolved executable. In that case, the spaces appear as
%20
in theLoadLibraryW
call which Windows is not happy about. This can happen, for example, when the resolved executable lives inProgram Files
.The following example demonstrates this behavior (using
native_add_app
again):This is running against the current
main
:Originally posted by @dnys1 in #55207 (comment)
The text was updated successfully, but these errors were encountered: