Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

System.DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll'
pgpacc
#1 Posted : Thursday, July 23, 2026 12:07:31 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/4/2026(UTC)
Posts: 6
Location: Denmark

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I very often get this error when running NCrunch:

Quote:

Exception occurred while testing (unknown migration)
System.DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.x86.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.Data.SqlClient.SNINativeManagedWrapperX86.UnmanagedIsTokenRestricted(IntPtr token, Boolean& isRestricted)
at Microsoft.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr token, Boolean& isRestricted)
at Microsoft.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr token)


The easiest fix is to add
Code:

    <CopyReferencedAssembliesToWorkspace>True</CopyReferencedAssembliesToWorkspace>


However, now I get a bunch of warnings
Quote:

The 'Copy Referenced Assemblies To Workspace' configuration setting for this component has been switched on.


Is there a way to either make it copy the dll without enabling CopyReferencedAssembliesToWorkspace,
or to suppress the "Copy Referenced Assemblies To Workspace" globally, so I don't have to do it for each project.
Remco
#2 Posted : Thursday, July 23, 2026 12:28:46 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,576

Thanks: 1036 times
Was thanked: 1394 time(s) in 1293 post(s)
Hi, thanks for sharing this issue.

The answer to this depends heavily on the nature of your dependency on this binary. It may be enough to simply reference it directly from your test project, as this way NCrunch will have the dependency details for it and the assembly resolution should work better.

How are you referencing this binary? Is it an unmanaged dependency of a different DLL you are using?
pgpacc
#3 Posted : Thursday, July 23, 2026 12:41:37 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/4/2026(UTC)
Posts: 6
Location: Denmark

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I have a reference to FuentMigrator.Runner

Code:

    <PackageReference Include="FluentMigrator.Runner" Version="7.0.0" />


And from what I can see, that has a reference to FluentMigrator.Runner.SqlServer -> Microsoft.Data.SqlClient -> Microsoft.Data.SqlClient.SNI

I'm not a big fan of having to include it directly in my test project, as I have 70+, and if FluentMigrator then decides to update, then I'll have to keep all my test projects in sync.
Remco
#4 Posted : Thursday, July 23, 2026 12:50:12 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,576

Thanks: 1036 times
Was thanked: 1394 time(s) in 1293 post(s)
One way or another, this assembly needs to be accessible at runtime.

Turning on 'Copy referenced assemblies to workspace' sets NCrunch in a compatibility mode so that runtime references get copied to the output directory, so that assembly referencing can work using the runtime's natural system.

It's usually possible to work without this setting, but that means either:
1. Ensuring that NCrunch has the correct information about the dependency by referencing it in your project
or
2. Copying the file into the runtime directory yourself using your own code inside your test run, or a custom build step

If the above options aren't suitable, then 'Copy referenced assemblies to workspace' is probably the right option for you. If you enable the advanced configuration mode in the NCrunch configuration window, you can enable this setting globally or for the entire solution, and the projects will just inherit it. The system will still warn you about it, but you can multi-select the warnings and choose to ignore them.
1 user thanked Remco for this useful post.
pgpacc on 7/23/2026(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.028 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download