Skip to content
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

Couldn't load assembly System.Data.SqlClient: System.AppDomain conflict in assemblies #1472

Closed
PoisonousJohn opened this issue Dec 19, 2017 · 15 comments

Comments

@PoisonousJohn
Copy link

PoisonousJohn commented Dec 19, 2017

I'm trying to use System.Data.SqlClient to work with Azure SQL, but I get exception during local testing.

Repro steps

  1. Clone repository: https://github.com/PoisonousJohn/CSharpHttpCore
  2. Launch project in VS or VSCode
  3. Execute function: http://localhost:7071/api/HttpTriggerCSharp

Expected behavior

Function fires without errors

Actual behavior

I get exception during function execution:

Exception during runtime resolution of assembly 'System.Data.SqlClient, Version=4.2.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a': 
'System.InvalidCastException: [A]System.AppDomain cannot be cast to [B]System.AppDomain. 
Type A originates from 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.3\System.Private.CoreLib.dll'. 
Type B originates from 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.3\System.Runtime.Extensions.dll'.

Known workarounds

No any workaround for me

Related information

Provide any related information

@PoisonousJohn PoisonousJohn changed the title Couldn't load assembly System.Data.SqlClient Couldn't load assembly System.Data.SqlClient: System.AppDomain conflict in assemblies Dec 19, 2017
@g4mb10r
Copy link

g4mb10r commented Jan 16, 2018

I am also having this issue.

@eschneider999
Copy link

I got this error while using a net standard 2.0 lib inside a project. I finally discovered a bad format error. Made sure the project platform matched in my case x64.

@g4mb10r
Copy link

g4mb10r commented Jan 18, 2018

@eschneider999 I don't think it's a configuration issue. If you start with a blank project and try to connect to SQL, you will get this error. Pretty serious in my opinion.

@christopheranderson
Copy link
Contributor

@fabiocav - you probably need to look at this. This is also probably the wrong repo.

@dkmiller
Copy link

dkmiller commented Feb 6, 2018

I am also encountering this issue.

@justin-lovell
Copy link

This issue is more of loading the wrong assembly version.

Packages reference <PackageReference Include="System.Data.SqlClient" Version="4.4.2" />

During runtime, the application is loading System.Data.SqlClient, Version=4.2.0.1

@justin-lovell
Copy link

If there could be any further insight, I also noticed the binding to Newtonsoft being version specific too.

@TheDruidsKeeper
Copy link

I just started a new project and ran into the same error as @justin-lovell, forcing x64 didn't make any difference. I had to downgrade the System.Data.SqlClient nuget package to version 4.4.0 (4.4.1 & 4.4.2 have this problem).

@jrummellelite
Copy link

@TheDruidsKeeper downgrading to 4.4.0 worked for me as well. Thanks!

@fmj-technologies
Copy link

Downgrading System.Data.SqlClient to 4.4.0 resolved the issue for me as well.

@fairwater
Copy link

I also had the same problem, and the downgrade made it go away for me too.

@BrodaUa
Copy link

BrodaUa commented Dec 4, 2018

Version 4.6.0 raises similar exception:
System.Private.CoreLib: Exception while executing function: FunctionApp. System.Data.SqlClient: System.Data.SqlClient is not supported on this platform.

Thanks to @TheDruidsKeeper, downgrading to 4.4.0 solved the problem.

@HeinBehrensRR
Copy link

Downgraded to 4.50 solved it for me

@mike1880
Copy link

Same issue here with 4.6.0, downgrade to 4.5.1 solved the problem.

@fabiocav
Copy link
Member

@BrodaUa @HeinBehrensRR @mike1880 ; the original issue here is quite old and doesn't apply to the current production versions of the runtime. Would you mind opening a new issue with the details requested in the template and error details so we can investigate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests