Error loading EntityFramework 4.3.1 - c#

I created an MVC application in C#. I created a new project in my solution called PhoneDomain. The purpose of this is to separate my data and domain layer from the actual problem. I right clicked on the project and went to "Add Library Package Reference" and I attempted to add the EntityFramework package (version 4.3.1). It said "Operation Failed" "This package contains an init.ps1 file and needs to be installed from the Package Manager Console".
So I opened the Package Manager Console in Visual Studio and typed the following into the console window:
install-package EntityFramework -project PhoneDomain
After a couple seconds, it installed the package and said Successfully added 'EntityFramework 4.3.1' to PhoneDomain
The problem is, when I run my application, I get the following error message: Could not load file or assembly 'EntityFramework, Version=4.3.1.0, Culture=neutral' or one of its dependencies. The system cannot find the file specified.
The reference in the PhoneDomain is definately there and the the Copy Local property is set to True.
Can anyone tell me what is going on here?

Check your web.config for assembly references. There may be a rogue reference in there.
UPDATE:
Also make sure ALL projects have the necessary reference...

Related

Dependency change results in missing reference to the old file

It happened I am responsible for maintaining an older C# application. The application connects to a MySQL server and for some reason the MySql.Data.dll was included on disk and checked in.
So I thought on changing this to reference using a NuGET package. I removed the dependency on the checked in binary and added a package reference.
Now when I build the application I get the following error:
"path\myproject.csproj" (build target) (1) ->
(GenerateApplicationManifest target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3987,5): error MSB3113: Could not find file 'lib\MySql.Data.dll'.
I tried to find any occurrence of that dll but there seems to be no reference anymore.
How to stop the project referencing the non existing library?
The problem was, that even though I removed the dll within Rider the deployment reference (<Content ...) within the csproj file was not removed.

VS error message while scaffolding identity

Can someone help me understand this Visual Studio error message and suggest a fix?
I am getting the error message while scaffolding Identity.
This is the error message I get:
There was an error running the selected code generator: 'Error: An
assembly specified in the applciation dependencies manifest
(Intacct.deps.json) has already been found but with a different file
extension: package:
'Microsoft.VisualStudio.Web.CodeGeneration.Design', version: '3.1.0'
path: 'lib/net461/dotnet-aspnet-codegenerator-design.exe' previously
found assembly:
'C:\MyPath\Users\MyUser.nuget\packages\microsoft.visualstudio.web.codegeneration.design\3.1.0\lib\netcoreapp3.1\dotnet-aspnet-codegenerator-design.dll
The issue was occurred due to the NuGet manager already has a reference for Microsoft.VisualStudio.Web.CodeGeneration.Design. in the C:\Users\Lenovo\.nuget\packages\microsoft.visualstudio.web.codegeneration.design\3.1.1\ folder in C drive.
As well as the reference was also available in the Project package
Follow the below steps to resolve the error,
Goto your project and Expand Dependencies tab
Expand packages and search for Microsoft.visualstudio.web.codegeneration.design(3.1.1) package
Right-click on the package name and Remove the package.
Build the project and try.
Only reinstall package.
open Tools-> NuGet package Manager-> Package Manager Console
Update-Package -reinstall

Dependency problems after update nuget packages of a VISX project

I'm creating a VISX project. It runs normally, but after I update all it's nuget packages, it start to show errors when I try to run it in the Visual Studio Experimental Instance.
I tried to revert the packages, but it seems that some packages versions are no longer available for download.
The main reason is that the VISX can't load the Microsoft.VisualStudio.Threading assembly after the dependecies are updated.
I tried adding the assembly to the package's Assets too. The VISX can load it now, but can't find the following method in the AsyncPackage class, like it would be loading the wrong assembly version.
JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
There's also the same error (assembly not found) for the Newtonsoft.Json dependency.
Can someone help me with this?
I zipped everything and upload in my onedrive: https://1drv.ms/u/s!AmhLdtS8gKjrl71Vmnp85m4ZPUILgw
I included all packages, since there's a chance that who download the project could not execute it because the packages could not be downloaded from nuget.org.
To simulate the error, just update the dependencies.
Update 1
As suggested, I was able to redo the entire project using "package reference" to target dependencies.
The visx builds and work, but the problem with the dependency for Newtonsoft.Json still occurs.
Also, I tried adding another dependency from a nuget package that I created, and the same error occurs too.
I wrote a piece of code that uses JsonConvert just to make use of the dependency.
When I execute the "TestCommand" from VS Experimental instance, them the error popups.
Link for the second project in my onedrive:
https://1drv.ms/u/s!AmhLdtS8gKjrl71ZCd1WIYNDTZaSCw

Assembly from nuget has strong name but cause build error of 'strongly-named assembly is required'

I successfully installed 'LiveCharts.Wpf' & 'LiveCharts' packages from NuGet, I use them in my code but when I want to build the project I get this error:
Unknown build error, 'A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Note that those packages have a strong name. You can see it in the attached image:
Thanks.
I had similar issue, after publishing and trying to build a newer version with VS2017. I switched, in the properties->publish -> application files, for the nuget settings to include. From:
To:
I still don't know what caused this problem, but I opened a new project and installed the packages with 'package manager console' and not from 'NuGet Package Manager' and it's work.

WCF Service is unable to locate System.Net.Http in release build only

I'm working on an error that I'm getting in a WinForms application that was recently updated from .Net framework 4.5.2 to 4.7. The issue occurs only after the application has been deployed. The error is originating from inside a WCF service (.svc) that I'm using. The specific error text I'm getting is:
Could not load file or assembly 'System.Net.Http, Version=4.1.1.1,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
In attempting to resolve this issue, I adjusted the App.Config file to bindingRedirect from System.Net.Http version 4.1.1.1 to 4.3.2 (which doesn't actually exist).
This resolved the issue with the service; however, when I made a call to System.Net.Http to download a string, the call failed. Presumably, this is because I directed System.Net.Http to use a dependency that does not actually exist (4.3.2).
This means currently I have a choice: either the service works, or calls directly to System.Net.Http work, but not both. Is anyone aware of how to make the service able find System.Net.Http 4.1.1.1? It is installed via NuGet... just seemingly not recognized unless:
1) I issue a binding redirect to a version of System.Net.Http that doesn't actually exist.
OR
2) I run the program in debug/release mode from Visual Studio (deployed release doesn't work).
I've found the issue, after several days of trouble. System.Net.Http is not published as it is supposed to be. It is a known issue (that is resolved, in theory), found here:
https://blogs.msdn.microsoft.com/bclteam/p/httpclient/
Issue 8
Symptom
ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Net.Http package may experience a TypeLoadException or other errors after being installed.
Resolution
This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:
1.Right-click on the project and choose Add Existing Item
2.Browse to the HttpClient net40 package folder
3.In the File name text box enter *.*
4.Holding CTRL, select System.Net.Http.dll and System.Net.Http.Primitives.dll
5.Click the down-arrow next to the Add button and choose Add as Link
6.In Solution Explorer, holding CTRL select System.Net.Http.dll and System.Net.Http.WebRequest.dll
7.Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
8.Republish

Categories

Resources