Open chandrashekharjoshi-abb opened 1 year ago
Update: if i change System.Memory nuget version to 4.5.4 which is 4.0.1.1, the i get error for System.Runtime.CompilerServices.Unsafe.
Pre-bind state information === LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///C:/ABB.SDS.SDK/host/Server/ LOG: Initial PrivatePath = NULL Calling assembly : System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: Using application configuration file: C:\ABB.SDS.SDK\host\Server\MOMServices.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: The same bind was seen before, and was failed with hr = 0x80070002.
Finally i could make it work by changing the version manually in packages.config file as below:
<packages>
<package id="Azure.Core" version="1.25.0" targetFramework="net48" />
<package id="Azure.Identity" version="1.7.0" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.1" targetFramework="net48" />
<package id="Microsoft.Data.SqlClient" version="5.1.1" targetFramework="net48" />
<package id="Microsoft.Data.SqlClient.SNI" version="5.1.0" targetFramework="net48" />
<package id="Microsoft.Identity.Client" version="4.47.2" targetFramework="net48" />
<package id="Microsoft.Identity.Client.Extensions.Msal" version="2.19.3" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Abstractions" version="6.24.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.24.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="6.24.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols" version="6.24.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.24.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="6.24.0" targetFramework="net48" />
<package id="Microsoft.SqlServer.Assessment" version="1.1.9" targetFramework="net48" />
<package id="Microsoft.SqlServer.Assessment.Authoring" version="1.1.0" targetFramework="net48" />
<package id="Microsoft.SqlServer.SqlManagementObjects" version="170.18.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Configuration.ConfigurationManager" version="6.0.1" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="6.0.0" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="6.24.0" targetFramework="net48" />
<package id="System.IO" version="4.3.0" targetFramework="net48" />
**<package id="System.Memory" version="4.5.4" targetFramework="net48" />**
<package id="System.Memory.Data" version="1.0.2" targetFramework="net48" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime" version="4.3.0" targetFramework="net48" />
**<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />**
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net48" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.ProtectedData" version="4.7.0" targetFramework="net48" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net48" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net48" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Json" version="4.7.2" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>
@chandrashekharjoshi-abb I am looking into the issue. I will update here, once I have it reproduced. As a workaround you can give try to assembly-redirect.
@chandrashekharjoshi-abb I am looking into the issue. I will update here, once I have it reproduced. As a workaround you can give try to assembly-redirect.
Thank you for the response, i have tried assembly redirect and it didn't fix the issue, but i can give it another try by referring to the link.
I am facing the same issue with Microsoft.Data.SqlClient v5.02. Assembly redirects won't work because I'm using an Excel COM add-in and don't have access to the Excel app config file. The only solution I have found so far is to add the redirect to the machine.config, but that's not practical for clients' computers.
I faced similar issue while working on WinForms. I added the nuget from Nuget.org through visual studio nuget package manager and inside the app.config I set the value to be like below somewhere inside configuration tag:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0"
newVersion="4.0.6.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Depending on what version you installed you can redirect to the correct number. I did not check if adding the package could fix the issue without changing the app.config.
Assembly redirect did not work for, since it created chain of errors, after solving one another appears. for me final solution was to do below changes in package.config, changed to lower versions for below package.
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
I am facing the same problem, and it ends up updating almost 50+ configs and add binding redirect everywhere for an enterprise software I am working on. 🤯🤯🤯🤯🤯🤯🤯
Same problem here.
I have the same problem when trying to create SqlConnection object in PowerShell, see cold below:
$cns = "Data Source=$SqlServerName;Initial Catalog=$SQLDbName;Authentication=Active Directory Default;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
$sqlcc = new-object ('Microsoft.Data.SqlClient.SqlConnection') $cns
Error:
The above issue also happens when you use the SqlServer
module as it uses DaxFx underneath.
Same. Mine is a .NET Framework Web API generated by the latest VS 2022.
-Jeff
I'm working on a Windows Forms application and I am receiving the error stating that "Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
Is there a fix for this issue?
This helped me in my case
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
The same for me when I was trying to update .NET Framework lib to use latest EF6 6.5.1
together with Microsoft.Data.SqlClient
version 5.2.1
and trying to use new Microsoft.Data.SqlClient
provider
Command:
Add-Migration UpdateEF6 -ConnectionStringName Dev
EDIT @Alexbits code also worked for me. Thanks
Hi, thanks for the suggestion, the solution worked.
Benim de başıma aynısı geldi, .NET Framework kütüphanesini en son EF6 sürümüyle
6.5.1
birlikte güncellemeye ve yeni sağlayıcıyı kullanmaya çalıştığımda.Microsoft.Data.SqlClient``5.2.1``Microsoft.Data.SqlClient
Emretmek:
Add-Migration UpdateEF6 -ConnectionStringName Dev
DÜZENLEMEK@Alexbitskod benim için de işe yaradı. Teşekkürler
The same for me when I was trying to update .NET Framework lib to use latest EF6
6.5.1
together withMicrosoft.Data.SqlClient
version5.2.1
and trying to use newMicrosoft.Data.SqlClient
providerCommand:
Add-Migration UpdateEF6 -ConnectionStringName Dev
EDIT @Alexbits code also worked for me. Thanks
Hi, thanks for the suggestion, the solution worked.
Describe the bug
When i add nuget package Microsoft.SqlServer.SqlManagementObjects 170.18.0 for SMO APIs(it also adds lot of dependecy packages), One of the dependency is Microsoft.Data.SqlClient, which is using old version of System.Memory 4.0.1.1 while package downloads 4.0.1.2.
we always get exception on SqlConnection.Open() function call. below is the fusion log:
To reproduce
Use Microsoft.SqlServer.SqlManagementObjects 170.18.0 and exectute SqlConnection
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
Expected behavior
A clear and concise description of what you expected to happen.
Further technical details
Microsoft.Data.SqlClient version: Nuget version 5.1.1 .NET target: 4.8 SQL Server version: 2019 Operating system: Windows Server 2016