Replacing dotnet core binary with private - c#

How do I replace a dotnet core binary with a private build of the same binary?
I have an application (that I own all the source code to) and I want to replace just a single dll with once that has a fix. Whenever I replace the binary I get the exception
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly '<my dll>, Version=2020.3.1.0, Culture=neutral, PublicKeyToken=null'.
The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: '<my dll>, Version=2020.3.1.0, Culture=neutral, PublicKeyToken=null'
at <call stack>
I've tried calling gacutil.exe -i but it didn't work.

Related

Error: Could not load file or assembly on Linux

I am using Ubuntu 20.04 and trying to run .NETCore Web App. I am using command
sudo /usr/bin/dotnet /var/netcore/publish/App.dll
where App.dll is Application.
I get an error:
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Hosting.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'Microsoft.Extensions.Hosting.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Any ideas?

Azure Function: Could not load file or assembly Newtonsoft.Json

I'm aware that this issue is widely covered on the web and at stackoverflow but I could do with some extra help to sort this issue. I'm getting a runtime error relating to loading Newtonsoft, see below;
[11/07/2020 18:37:17] A ScriptHost error has occurred
[11/07/2020 18:37:17] Exception while executing function: Alerts. EmailSender: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. mscorlib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
[11/07/2020 18:37:17] Exception while executing function: Alerts
[11/07/2020 18:37:17] Exception while executing function: Alerts. EmailSender: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. mscorlib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
[11/07/2020 18:37:17] Function completed (Failure, Id=850be268-8e38-409d-aa59-fa071567779e, Duration=10672ms)
I have followed and implemented binding redirects as described in this blog. My azure function is a verion 1 function with .net472, im using Microsoft.NET.Sdk.Functions Version 1.0.36.
The exception occurs when a call to a referenced project is made, in that project there is a reference to Newtonsoft 10.0.2.
Any help is greatly appreciated - thanks!
You'll need to downgrade Newtonsoft to 9.0.1. You'd better read about the v1/v2 breaking changes and rewrite your function to .net core.
https://github.com/Azure/app-service-announcements/issues/129

VS Installer Project is not pulling in all system.io.compression

I have a solution written in C# on .Net 4.6.1. The 2 projects are Windows Service and VS Installer. The windows service project has many references with 2 of them being system.io.compression and system.io.compression.filesystem.
The project compiles without error; however, when I compile the VS installer project I'm getting a missing file error for system.io.compression. I refresh the dependencies but the reference still doesn't show up. Why doesn't the installer project pull in the reference from the windows service project while all the other resources are available?
I've tried removing and re-adding the reference to the windows service project
I've tried adding the file referenced in the windows service project to the File System > Application Folder and it compiles with no errors but when installed and running I get the following error
System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'System.IO.Compression, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ---> System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. at efaactagent.Archive.Zip(String sourceFile, String destinationFile) at efaactagent.Jobitem.LogManagement()
check your *.config in all projects
Try to remove all bindings redirects and regenerate them again via PM> Get-Project –All | Add-BindingRedirect

'Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I am a newbie and just created a new project of type: ASP.NET Core Web Application (.NET Core) and let VS preload all the defaults. I changed nothing, except set index.cshtml the startup. It built ok, but has a run-time error of:
System.IO.FileNotFoundException occurred
HResult=0x80070002
Message=Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Call Stack (last item):
ntdll.dll!NtWaitForSingleObject() Unknown
What is happening here, and how can it be fixed?
Using Visual Studio Installer, selecting the Repair option solved the problem.

Passing the paths of nuget installed assemblies to mono runtime

I have Visual Studio project that I am trying to get running with Mono.
I could install all dependencies using
mono nuget.exe install
and compile my application using
mcs -r:RestSharp.105.2.3/lib/net46/RestSharp.dll \
-r:JWT.1.3.4/lib/3.5/JWT.dll \
-r:jose-jwt.2.2.0/lib/net461/jose-jwt.dll \
-r:Newtonsoft.Json.10.0.1/lib/net45/Newtonsoft.Json.dll \
Program.cs
Now I am trying to run the application using
mono Program.exe
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies.
File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
So how do you pass the path to the assemblies to the Mono runtime similar to the compiler?
I tried to set $MONO_PATH but this is not working and not recommended for Production.
The overall question how the mcs compiler and the mono runtime could get the information directly from the installed packages (using nuget.exe).

Categories

Resources