Could not load type 'System.Data.Common.DbProviderFactories' from assembly 'System.Data' - asp.net

First of all some context: my project exists out of a common project that contains all the DAL stuff and a web project. Now the common project is written in .NET framework 4.5 while the web project is written in .NET Core 2.0.
When trying to acces the repositories of the DAL project I get following error:
Could not load type 'System.Data.Common.DbProviderFactories' from assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Now I'm not sure what to do now. I have added the System.Data.Common nuGet package to my web project, but without succes. How can I slove this problem preferably without altering the common DAL project? Thanks in advance.

Related

Getting 'could not load file or assembly' error in .NET Core 2.0

I am getting the below error:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'
What I did:
Created new project in .NET Core 2.0.
Added project reference of class library built out in .Net framework 4.6.1.
Access function from class library which is using System.Data.OracleClient for database connection.
But it's failing while invoking function with above error.
How do we support accessing old .NET libraries built out earlier with lot of internal references in .NET Core project?
Unfortunately, you cannot.
Your project built with .NET Core must have only libraries built for .NET Core. You can't use the one built for .NET Framework.
Here is a quote from the book ASP.NET Core in Action when deciding to develop with .NET Core rather than .NET Framework:
The largest obstacle you’re likely to come across is a third-party
library holding you back, either because they only support older
ASP.NET features, or they haven’t been converted to work with .NET
Core yet.

Why is my project failing to reference the System.ComponentModel assembly?

My project is set to .NET Framework 4.5. I get the following error when attemping to use SimpleIOC (from MVVM Light) in my WPF project:
Error 3 Reference required to assembly 'System.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the implemented interface 'System.IServiceProvider'. Add one to your project.
I can't figure out why it's giving me this error. From what I understand, this is a mscorlib class so I'm not sure where it is getting System.ComponentModel from.
I can write Dim test As IServiceProvider without the compiler complainging. Is there some kind of version issue?
It seems like a possible Visual Studio bug. I created a new WPF project and was able to find the System.ComponentModel.dll in the list of .Net Framework assemblies. For my current project, I ended up browsing to it to add a reference to it. All is well now.

Downgrade from EF6 to EF5

Does EF6 not work with ASP.NET MVC 4? I've tried to downgrade to EF5. But when I run my web app. I'm getting this error:
Could not load file or assembly 'System.Data.SqlServerCe.Entity,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or
one of its dependencies. The system cannot find the file specified.
And when I was using EF6 I was getting a NULL value on LINQ operations. For more info.
How do I fix this please?

Ninject assembly does not match referenced assembly

Setup:
ASP.NET MVC3
Ninject v2.2.1.4
Ninject v3.0.0.15
Ninject.MVC3 v3.0.0.6
Ninject.Web.Common v3.0.0.7
Using NuGet, my UnitTest project references Ninject v2.2.1.4
My Web Project references Ninject v3.0.0.15, Ninject.MVC3 and Ninject.Web.Common
Problem:
With win explorer open at the bin folder of my web project, I build my solution and I can see Ninject v2.2.1.4 copied into the bin directory of my web project. And then being replaced by Ninject v3.0.0.15.
When i hit F5 to debug, Ninject.dll v3.0.0.15 gets replaced with Ninject v2.2.1.4 causing the following error :
Could not load file or assembly 'Ninject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
What gives?
Some thoughts:
Only in your debug build did you have an indirect reference to the
v2 Ninject version. Case in point, I'm guessing when you are doing
your debug build you build your Test project while a release build
does not build your Test project.
When you were building, did you happen to notice what project was being built when the v2 DLL was placed in the bin? Then you'll be
able to figure out what project is referencing the v2 build and be
able to narrow down your search (i.e. the answer would become quite a bit more obvious if it wasn't the Test project).
Never a good idea to reference multiple versions in different projects.
Did you check out what your Web.config and App.config references were pointing to?

Why can't I reference the project I created earlier from my wcf service class library?

Warning 1 The referenced assembly "C:\Users\rzv\Desktop\CompanyAnalyse1.0\AnalyserModel\bin\AnalyserModel.dll" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
Why do I get this? AnalyserModel is a class library that uses Entity framework code first 5 to save data in a database. I tryed to create a new WCF service application that uses the methods in AnalyserModel. What is wrong?
You need to change the target framework from 4.0 client profile to 4.0.
you can do this on the projects properties page.

Resources