-
Notifications
You must be signed in to change notification settings - Fork 48
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
Exception when using/referencing packages with native libraries #390
Comments
Most likely |
That being said, aren't all libraries supposed to be embedded into the vsix? In the post's sample project, the debug/release folder will have the native libraries as expected, but once loaded into VS via VSIX, native libraries are not there (or are not found) and it doesn't work inside the extension. |
If you open up the VSIX file (it's just a renamed zip file), do you see the dependencies you expect embedded in the zip? |
My guess is that you would want those libraries to be packaged in the VSIX, you would then use Assembly.GetExecutingAssembly to get the installation folder of your extension and figure out the path of your native library so that you can set |
Yes, the native libraries are inside the vsix.
The native libraries also are in the installation folder. Thanks, I was able to workaround with:
That being said, I don't need to do this for a regular console project which has the exact same folders. Also, the GlobalSettings path applies to all extensions running under the same Visual Studio instance, which means that if a another extension points to a different path/version it would cause conflicts. Other than that, the workaround provided above and could close this issue - assuming no one has anything else to add. |
When LibGit2Sharp is referenced, all of the native library info is in the dep.json file, so the normal .NET runtime type loading mechanisms should be able to work to choose the correct native library. When the extension assemblies are being loaded, are you using a custom AssemblyLoadContext to do that? @luislhg should not need to manually provide the path to the native binary in this case. It seems like something the VSExtensibility should be handling. |
I was able to reproduce the issue and will be opening a work item to create guidance. I did notice that we currently don't deploy deps.json file as part of the extension but adding a target as below to deploy it didn't help either. We will have to investigate further. Thanks, You can add the below to csproj to include deps.proj files: <Target Name="IncludeDepsJson" BeforeTargets="GetVsixSourceItems">
<ItemGroup>
<VsixSourceItem Include="bin\$(Configuration)\$(TargetFramework)\ExtensibilityNativeLibraries.deps.json" />
</ItemGroup>
</Target> |
Glad that you managed to reproduce and work on it. Some notes/questions I found:
|
The works because with a single runtime identifier, native assemblies are added to extension directory directly. But as you said it wouldn't work for Visual Studio for ARM64. Both extensibility scenarios for Visual Studio do support arm64 and extension host for out-of-proc cases should be a native arm64 process. |
Hello, I'm trying to develop an extension that uses libgit2sharp, which has native libraries. It fails when trying to use it with this exception
The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
InnerException = {"Unable to load DLL 'git2-a418d9d' or one of its dependencies: Não foi possível encontrar o módulo especificado. (0x8007007E)"}
Here is a reproduceable project, it's very simple, just added a nuget reference to a package using native libraries, and this fails in the extension project. It works nicely in a console project for example.
ExtensibilityNativeLibraries.zip
The text was updated successfully, but these errors were encountered: