Issue with the Photon App Domain loading Dlls

I upgraded my nuget packages today and now when I try to run my photon application it is unable to load the correct version of the Microsoft.Extensions.Configuration.Abstractions. It tries to appear to load version 1.0.2.0 but we are on version 2.1.2.0. The dll is present in the dll and is the correct version(2.1.20) but I dont understand why Photon App Domain is not using the binding redirect like another .net framework application. The dll that hosts the ApplicationBase class is MGF.Photon.dll

Error message:Exception:System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.File name: 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at MGF_Photon.PhotonApplication.Setup() at Photon.SocketServer.ApplicationBase.PhotonHostRuntimeInterfaces.IPhotonControl.OnPhotonRunning() at PhotonHostRuntime.PhotonDomainManager.PhotonPlainAppDomainBehavior.PhotonRunning() at PhotonHostRuntime.PhotonDomainManager.PhotonRunning()

the binding redirect in the app.config file and in the MGF.Photon.dll.config

MGF.Photon.dll is using the .net framework 4.6.1 Photon server v4.0.29.11263 Microsoft.Extensions.Configuration.Abstractions.dll is a net standard 2.0 lib so it supports all .net frameworks from 4.6.1 and below.here is the link to the confing file

@JohnTubeWe made it our self with a bit of help with Christian Richards. We have heavily modified his framework to meet our need. It is a framework hides away the socket server details so if we switch away from Photon we dont need to rewrite the whole application. However, this is not an issue with framework or anything since we are not even getting into the main assembly of the application, and photon having issues loading the related assembly. This is only a photon issue because when I try loading the MGF.Photon.dll in a console application using the Assembly.LoadFile method, the CLR is able to find and load the correct versions of the ref assembly. I do see that Photon is doing some custom assembly resolving and more custom CLR related classes. It appears that Photon is not respecting binding redirect

>Microsoft.Extensions.Configuration.Abstractions.dll is a net standard 2.0 lib so it supports all .net frameworks from 4.6.1 and below.

Here is the place where as I think you are wrong. netstandard 2.0 is not supported by .net framework 4.0 which is used by photon. so, libraries that depened on API from netstandard 2.0 can not be loaded by photon.

So, it is not photon issue at all. Just use correct versions of your dependencies

@chvetsovso i have a working example of another server that uses the .net framework 4.61 and standard 2.0. If you answer was correct, I would not be able to create a working solution using those two frameworks. So either I did something magically with the test solution or your statement is wrong.

@chvetsovSorry the example that does work using .net framework 4.61 and standard 1.6, and load correctly however we downgraded our game servers code to .net framework 4.61 and standard 1.6 and we are still getting the error loading the Microsoft.Extensions.Configuration.Abstractions assembly, which seem to be causing when we try to load the Autofac library; however, if we load the assembly manually using the Assembly.Load api, then the error does not happen. This point to an issue with the AppDomain not using the common method for loading assemble into the CLR that a normall CLR application does. This is also supported by the fact that in the logs, just right after the log message about the System.IO.FileNotFoundException is print, there is a bunch of log statements related to trying to download the file from different locations. It looks like AppDomain is able the file "Microsoft.Extensions.Configuration.Abstractions.dll"; however, the version are different(there is a message about minor version are mismatch). I check the configs files for the correct bindingRedirect and the config files point version in the bin file(v 2.1.1.0) to be used for version 0.0.0.0-2.1.1.0

Exception:System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.File name: 'Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' at MGF_Photon.PhotonApplication.Setup() at Photon.SocketServer.ApplicationBase.PhotonHostRuntimeInterfaces.IPhotonControl.OnPhotonRunning() at PhotonHostRuntime.PhotonDomainManager.PhotonPlainAppDomainBehavior.PhotonRunning() at PhotonHostRuntime.PhotonDomainManager.PhotonRunning()

Photon uses the LoadFrom method to load assemblies. Because Load does not allow you to load the assembly from a custom path.After start current directory is set to deploy folder. And as far as I may see Assembly resolver tries to find your libraries there, plus in some predefined paths like (deploy/bin and deploy/Shared). I think you should use those paths.I cannot help you more here. This is not really photon issue

This is a photon issue, this is not related .Net framework, we have open a ticket with the MS Support and they have conclude that using .net framework 4.61 and standard 1.6 should work with the server, and that we should contact the product team to addition support, because we can get it work with a test solution using .net framework 4.61 and standard 1.6 if this was a .Net Framework issue then it would complete impossible to do(which hint hint is not impossible since i can create a sample solution that work ). The dll is in the deploy\bin(we are running photon in debug mood so we can use the debugger to step into the code). This leans me to believe there is config issue or photon issue.

Note if i add this code the whole works perfectly all i have to add that method to the AssemblyResolve event on the current domain(Hint hint, if this was a .Net Framework this would work since the CLR would not allow it hint hint)

//Loop through the array of referenced assembly names. foreach (AssemblyName strAssmbName in arrReferencedAssmbNames) { //Check for the assembly names that have raised the "AssemblyResolve" event. if (strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(",")) == args.Name.Substring(0, args.Name.IndexOf(","))) { //Build the path of the assembly from where it has to be loaded. //The following line is probably the only line of code in this method you may need to modify: strTempAssmbPath = this.BinaryPath +"\\"; if (strTempAssmbPath.EndsWith("\\")) strTempAssmbPath += "\\"; strTempAssmbPath += args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"; break; }

@chvetsovFirst .Net Framework CLR would complain about loading an dll that is not compactable the current CLR version, and the exception that would would not be a System.IO.FileNotFoundException(the dll cant be found) but it would a System.IO.FileLoadException(the dll can be found however there is exception in loading the dll into the appdomain).