We are developing a .NET windows application and decided to use ClickOnce instead of just copy/paste files from release folder.
After deployed and installed on user machine, we started to have the following error:
System.IO.FileNotFoundException: Could not load file or assembly System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
We saw that this file was not being deployed together with the application and found this Question Deploying System.Net.Http.dll with ClickOnce but says microsoft would solve the problem. We are using VS2017 and seems like the same result.
Could not find what to do to fix this without a workaround. Does anyone know how to fix?
You can remove the reference that points to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X.X\System.Net.Http.dll and simply add the System.Net.Http NuGet package.
This will be deployed without problem.
Related
Well I have a problem, we upgraded the .net framework from version 4.0 to version 4.6 of .net, I have about 9 projects running and I had to install masstransit and autofac in 2 projects, this caused some libraries to be updated or installed in other projects.
At the moment in one of the projects(Team.Services) I have installed the 4.5.2 version of the library System.Threading.Tasks.Extensions, before of this I had the version 4.2.0.0, but now I update this. The image below you can see that it is version 4.5.2.
Now when I see the references of the project I can see that I do not have the correct version referenced, it is as if another dll was installed
look for the solution(link below) in other places, also try to change the version in the app.config check the version in the package.config clear the nuget cache and reinstall everything. and it is not working, it keeps looking for the old dll and for this reason it doesn't find the new dll, besides the installations seem to be a different version.
DLL hell - Could not load file or assembly System.Threading.Tasks.Extensions
This is the error:
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
Source=Team.Services
StackTrace:
at Team.Services.ServiceFactory.StartServices(String applicationDirectory) in C:\Users\amilkar.contreras\source\repos\TFS.TeamServices\Common\Team.Services\ServiceFactory.vb:line 110
at Team.ServiceHost.Service.OnStart(String[] args) in C:\Users\amilkar.contreras\source\repos\TFS.TeamServices\Hosts\TeamServiceHost\Service.vb:line 25
at Team.ServiceHost.Service.Start(String[] args) in C:\Users\amilkar.contreras\source\repos\TFS.TeamServices\Hosts\TeamServiceHost\Service.vb:line 34
at Team.ServiceHost.Program.Main(String[] args) in C:\Users\amilkar.contreras\source\repos\TFS.TeamServices\Hosts\TeamServiceHost\Program.vb:line 41
You can have a try the possible solution to solve it:
Confirm the Package Management is Package.config in visual studio, then reinstall this package again
delete .vs folder then restart visual studio
Remove this dll manually, then add the new dll as reference manually
The exception when running as the console application as Azure webjob:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Azure.Core, Version=1.0.2.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Locally this works and runs.
Referencing:
Azure.Identity version 1.3.0 which has a dependency to Azure.Core version >= 1.6.0
Azure.Security.KeyVaults.Secrets version 4.1.0 which has a dependency to Azure.Core version >= 1.0.2
So of course based on these nuspec specifications it should resolve to Azure.Core 1.6.0. Which it locally does and runs without a problem.
Yet when I deploy this using VS publish profile to our cloud as Azure Webjobs and run the application I get the exception mentioned above. (of course the file version deployed is the same as local, version 1.6.0)
I know I can fix this with an assemblybinding. Stating that version 0.0.0.0 to 1.6.0.0 should resolve to version 1.6.0.0.
But I find this very frustrating because it imposes manual labor and keeps us from updating packages whenever a newer version arrives because then we also have to remind ourselves to update the assemblybindings.
I feel like there is a better solution, or we are doing something wrong. But I simply do not know where to begin searching for a solution. I hope to get some insights from you guys!
PS:
This phenomenon is driving me nuts because we face similar issues when using packages:
Unity
Unity.Interception
Because they both depend on Unity.Container. Forcing us to either use assemblybinding to resolve this issue, or only use versions which depend on the same packages
Try doing the following steps because the approach you are taking is correct:
Uninstall both Azure.Identity and Azure.Security.KeyVaults.Secrets nuget packages.
Remove all the associated Assembly Bindings.
Delete bin and obj folders in your project folder.
Install Azure.Core version >= 1.6.0 and rebuild the solution.
Deploy the solution.
These should work ideally. I think that there are some stale dependencies which are getting deployed. You can also try deploying through pipelines, if not already doing.
I have built an application using C#. I had referenced ODAC version 4.121.2.0.
When I deployed my application on the server, the application failed with error:
Unhandled Exception: System.BadImageFormatException: Could not load file or asse
mbly 'Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b4
83f429c47342'. This assembly was compiled for a different processor.
The server only has 4.121.1.0 installed.
What do I need to do to make application work? Things I tried:
1. In the .csproj <SpecificVersion>False</SpecificVersion>
<Private>False</Private>
2. I tried copying over the ODAC version (4.121.2.0) in the bin solution directory(of the server), it wouldn't work.
3. I tried removing all ODAC dlls in folder, so that it can find out older version and use that for functionality.
I do not want to install older version on my local and then - I have tried this in the past and I ended up uninstalling all the versions.
Possible duplicates:
Having two ODP.NET (ODAC) versions in the same server
How do I get an older version of OracleClient to work locally with .NET?
oracleclient-to-work-locally-with-net
But these links didn't provide solution for my problem.
I think the error your are getting is not related to a dependency versioning issue. A BadImageFormatException usually gets thrown when there are 32Bit/64Bit incompatibilities between the entry point (i.e. exe file) and one of the dependencies.
Try playing with the target platform when you compile the project(s) (Any CPU/x86/x64 and the Prefer 32-Bit project property).
Hope it helps!
Getting an
Could not load file or assembly 'System.Net.Http, Version=4.2.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified." exception
after publishing to Azure as an App Service.
I have created a ASP.NET Wep API application using Entity Framework DB First approach.
I did not use any NuGet package to install System.Net.Http, it was added automatically when the project was created. The latest version is 4.2.0.0.
It works fine when I run on my local IIS (IIS Express).
I published this app as an Azure App Service successfully but it does not open the API Home page. Instead I get the above mentioned exception.
I tried using bindingRedirect in Web.config but it does not help.
I am new to Azure and not sure how the dlls are deployed.
Any help is greatly appreciated.
Upgraded project to 4.7.2.
Turns out Visual Studio 2017, when installing the .NET 4.3.3 Nuget package for System.Net.HTTP is also adding DLL reference from the GAC. This in tandem with an Assembly redirect causes run time System.IO.FileNotFoundException looking for version 4.2.0.0 of System.Net.Http.
The good news, is to add references, uncheck System.Net.Http from the GAC (which was added automatically or by other developers in the project at one point in time), and simply delete the Assembly redirect.
For more details, you could refer to this article.
I think found the cause of the issue. My project is using .Net framework version 4.7.2 and on Azure the app service is using .Net framework version 4.7. So changing the target framework in my project properties to 4.7 seems to work.
I added HtmlAgilityPack dll(1.8.5 version) as reference in my SSDT VS 2010 solution.
But i got error message like
Could not load file or assembly 'HtmlAgilityPack, Version=1.8.5.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a' or one of its dependencies. The system cannot find the file specified.
Note : I don't have permission to download dll from Nuget in my original solution so i downloaded dll from another server through Nuget and added that dll in my original solution as reference. Actuall DLL is not in packages folder in my solution.
Please help me on this.