-
Notifications
You must be signed in to change notification settings - Fork 297
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
Native libraries not loaded in C# interactive #675
Comments
Hi @mrmonday , I tried with your csproj file and is able to reproduce it locally. For System.Data.SqlClient, it's part of System.Data.dll which is included with .NET Framework. And it doesn't depend on SNI.dll explicitly. For Microfost.Data.SqlClient, it's a separate nuget package and depends on another Microsoft.Data.SqlClient.SNI nuget package. We have similar issues loading native SNI.dll when using Microsoft.Data.SqlClient with F#: For web and console app, the dependency is handled by nuget package manager and the required SNI.dll is copied along with driver in the bin folder. If you execute the binary from bin, it works without error. However, this does not work with the interactive window in Visual Studio which cannot load SNI.dll even though it's already in the bin folder. I tried to add Microsoft.Data.SqlClient.SNI as package reference to the csproj but that doesn't work either. In addition, I tried to add SNI.dll with #r command but it doesn't work with native assembly:
After I manually copied the SNI.dll to the Directory.GetCurrentDirectory(), the c# interactive shell can find the native dll properly. |
@karinazhou Have a look here - it's for F# scripts but this solution might work here as well. |
@isaacabraham Thank you for sharing your blog. |
We have similar issue in Microsoft Service Fabric - after upgrading to version 2.0.0/1, our microservices are throwing this exception:
These are all using .NET Core 3.1 |
Closing this issue as native SNI support for C# interactive cannot be configured with SNI targets.
Regarding following discussion, pdbs have been removed from Microsoft.Data.SqlClient.SNI.runtime v2.1.1 to be picked by Microsoft.Data.SqlClient v2.1.0-preview2 onwards. |
But this is not recommended by Microsoft |
Using the following project (
SqlClientInteractive.csproj
):Code (
Conn.cs
):In Visual Studio (tested with 2019, v16.6.5), right click the project, then "Initialize Interactive with Project". Run
Conn.Open()
.Using
System.Data.SqlClient
, this works correctly.When using
Microsoft.Data.SqlClient
, this gives the following exception:Debugging gives the following:
As part of a larger test case, I am able to work around this with the following snippet - unfortunately this does not seem to work for the reduced test case as given here:
The native library seems to be loaded correctly in web and console applications, but not in an interactive shell.
The text was updated successfully, but these errors were encountered: