Question: Is there any way in .NET Core 2.0 (netstandard 2.0), how could I apply assembly redirects not defined in the given application.exe.config file when I run the executable? Maybe some kind of software path? Or even by running an executable file with some special settings / flags?
Scenario: Here is a simplified scenario that I am trying to solve in .NET Core 2.0.
- There is an executable file "service hosting", call it
ServiceHost.exe - There is a
.dll service, let's call it Service.dll , which implements some IService input interface using the Start() method. - When I run
ServiceHost.exe --service-assembly Service.dll , it loads the service and calls its implementation of IService.Start() . - Anyone can be the author of a service; it is independent of the service host.
Let's say that the service needs some assembly redirects. This is pretty common in the .NET Core world when you refer to a lot more packages than the old .NET Framework, and not all of them have exact versions for the latest .NET Core. Using assembly redirection works quite well and allows you to use the target version of the library with an older version.
And here is the problem with my setup. Because Service.dll is a library loaded by an independent executable, the app.config file with assembly redirection is not used. The runtime uses ServiceHost.exe.config , not Service.dll.config , as expected.
Reminder: I am using .NET Core, so a solution with creating a new application domain and installing it to load another configuration file is not an option.
source share