Good morning, I am working on a simple ASP.net application. I have implemented some code which is in C# dlls. Those dlls are used and loaded by the ASP.net application. The goal is to put the C# dlls outside of the project, in a specific folder, (for example C:\users\Dlls) and use them in the ASP.net application. When I debug in Visual, I saw that there are different application domains. For what I understand, the first application domain is the default one : 'iisexpress.exe' (CLR v4.0.30319: DefaultDomain)
And after that I have another one :
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/2/ROOT-1-132768598652050662)
I have made some code with using assembly resolver system to load my own assemblies in the second application domain (/LM/W3SVC/2/ROOT-1-132768598652050662) and it works fine.
Now, I would like to load my own assemblies in the application domain called "DefaultDomain" but I did not succeed it. I have tried assembly resolver but it does not work.
For debugging, in order to have a list of which assemblies are load by "DefaultDomain", I have used this following method :
private static AppDomain GetAppDomain(string friendlyName)
{
IntPtr enumHandle = IntPtr.Zero;
ICorRuntimeHost host = new CorRuntimeHost();
try
{
host.EnumDomains(out enumHandle);
object domain = null;
while (true)
{
host.NextDomain(enumHandle, out domain);
if (domain == null)
{
break;
}
AppDomain appDomain = (AppDomain)domain;
if (appDomain.FriendlyName.Equals(friendlyName))
{
return appDomain;
}
}
}
finally
{
host.CloseEnum(enumHandle);
Marshal.ReleaseComObject(host);
host = null;
}
return null;
}
I get the list of assemblies with that :
AppDomain appDefaultDomain = GetAppDomain("DefaultDomain");
Assembly[] tabAssembliesAppDomain = appDefaultDomain.GetAssemblies();
With debugging, I have check the setup information of the "DefaultDomain" :
I am wondering if I change the "ApplicationBase", "PrivateBinPath" or "PrivateBinPath" fields it could resolve the problem but I think it is a part from a configuration of IIS server. Also I see that there is a configuration file iisexpress.exe.config but it doesn't exist. Maybe I have to create one but I don't know how to do it.
Thank you in advance for any help.