Could not locate EntityFramework dll when publishing to Azure - c#

I am trying to publish an MVC app and SQL Server DB to an Azure website.
Everything builds and loads fine when I run locally from within Visual Studio. However when trying to publish to Azure, I get 13 build errors which are all basically because the DLLs for EntityFramework cannot be found.
Warning 2 Could not resolve this reference. Could not locate the assembly "EntityFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. RMoney.Data
Warning 3 Could not resolve this reference. Could not locate the assembly "EntityFramework.SqlServer". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. RMoney.Data
I have enabled the option to allow NuGet to download missing packages (I added EF via nuget).
I have set all DLLs to be 'copylocal=true' too.
I have published other Azure Websites without an attached SQL DB with no problems.
Any idea what I might have done wrong?

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.

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

How can fix System.InvalidOperationException = Unable to create service from type 'My type'?

I've got a web service that references a set of dlls that are currently version 6. I was given version 7 dlls to upgrade to, so I registered the new dlls in the GAC, removed the references in my project to the old dlls and added references in for the new ones. No problems so far.
I then proceeded to alter the App.config, which had references to these dlls and changed their version number to 7.0.0.0 from 6.0.0.0 and built the project. No errors or warnings.
Finally, I installed the web service and tested it out and got the following error:
[System.InvalidOperationException] = {"Unable to create service from
type 'the type,
dll name, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=My token'."}
As I don't have access to the code in the dll's I don't know if it's something in them that's not working or whether it's perhaps a permissions / connection issue. Does anyone have some suggestions?
Press Ctrl + Q in Visual Studio in order to start texting in quick launch text box. Then type 'verbosity'. Change build output verbosity into 'Diagnostic' and analyze your build. That helps a lot in that cases.

AppHarbor ASP.NET Google Spreadsheets Hosting

I have recently created a ASP.NET Website using Visual Web Developer 2010. In my code, I am using these references in order to access Google Spreadsheets:
Google.GData.Client
Google.GData.Extensions
Google.GData.Spreadsheets
After pushing the project to the AppHarbor website using Git Shell, I am receiving the following errors:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.GData.Client". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\temp\orluajnw.mop\input\DVPT\DVPT\DVPT.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.GData.Extensions". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\temp\orluajnw.mop\input\DVPT\DVPT\DVPT.csproj]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Google.GData.Spreadsheets". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\temp\orluajnw.mop\input\DVPT\DVPT\DVPT.csproj]
How can I prevent these errors and include these references? All help would be greatly appreciated.
It seems you may be referencing those dlls from the GAC.
In that case, since they won't be available in AppHarbor's build machine's GAC, you will have to include the dlls inside the code you upload.
One easy way to do it, is to create a libs folder (at the same level where your solution is would be a good location), and place all the required dlls there.
Then remove the existing references to those dlls from your current project, and add them again but from that libs folder. Also, for each of those references, it may be necessary for you to set the CopyLocal property to True (if you click on the reference you will see CopyLocal in the Properties Tab below the solution explorer).
More info on Copy Local can be found here:
http://msdn.microsoft.com/en-us/library/vstudio/t1zz5y8c(v=vs.100).aspx
That way, AppHarbor will be able to build the code, since it will look for those dlls in that libs folder that you have just uploaded along with the rest of the code.

Could not load System.Data.SqlServerCe.Entity.dll (Yet it's there)

I have a silverlight application. The server app has an SQL Server CE 4 .sdf in App_Data, and an ADO.NET model generated from it.
If I try to Add->New Item->Domain Service Class, I get the error:
Schema specified is not valid. Errors:
Models.TasksDatabaseMode.ssdl(2,98): error (0004): Could not load
System.Data.SqlServerCe.Entity.dll. Reinstall SQL Server Compact.
However, I installed RIAServices.EntityFramework and EntityFramework.SqlServerCompact via NuGet, which has successfully downloaded this .dll to /packages, and the file has been copied out into the /bin folder. So I have no idea where it is apparently looking for this .dll, if not there.
Perhaps related, I was earlier attempting to have the database generated code-first. However, the Domain Context Wizard was also failing, but with an error about an index being out of bounds. With a manually written service, the build was failing with a MetadataWorkspace error, about which I couldn't find any information.
Does installing the runtime directly (http://www.microsoft.com/en-us/download/details.aspx?id=17876) fix the issue?
Also, what version of the binary are you using? I suspect that you may have the private version (4.0.0.1) and generation is expecting the machine version (4.0.0.0)

Categories

Resources