the situation is quite complex ( and my english very basic) but let's try to explain:
i'm developing a Asp.net web service calling a method from an external dll.
This external dll calls some method from other .net dlls.
So we have:
Asp.net WS ----> External.dll ----> other.NEt.Dll(---> other .netdll)
You have to know that the external dll uses a path ( given by an initialize method) to resolve its internal reference.
In conclusion i have a web application with an added reference to my External.dll and a fully trusted path ( c:\EXTERNAL ) full of all the .net dlls needed by external.dll.
Looking around i've found this code to add to the application_START:
Dim path As String = String.Concat(System.Environment.GetEnvironmentVariable("PATH"), ";", "c:\EXTERNAL)
System.Environment.SetEnvironmentVariable("PATH", path, EnvironmentVariableTarget.Machine)
this add my c:\EXTERNAL to global environment PATH.
With this configuration running from the Visual Studio development server i get no error and it all works correctly.
When i publish the application on my local IIS server it gives various errors: At first the result is something like:
Failure reading <Myobject> control of <(static)> type
Unable to create <myobject> object (<C:\(WRONGPATH)\needed.net.dll> assembly)
To resolve this i've tried to add the needed .net dlls to the /bin of my application in wwwroot but the result is something like:
Failure reading <MyType> control of <Myobject> type
Error returned by .NET Framework:
System.ArgumentException: Un oggetto di tipo 'ComNet.BaseControl.LoginDisplayLayout' non può essere convertito nel tipo 'ComNet.BaseControl.LoginDisplayLayout'.
in System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
in System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
in System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
in System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
in System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
in System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
in CDotNetType.bSetProperty(CDotNetType* , Object gcrObj, SByte* pszNom, CSLevel* pclPile, Int32 nDimension, Int32* pnTabDimension, STOperationDotNet* pstOperation)
this time it looks like it's loading the same dll but from different location causing conflicts.
Now that's all. Its hard for me to explain this dll-hell but basically i would like to replicate whats happening when the application works well in the visual studio development server. I've also read that IIS does not resolve Added PATH without rebooting so i tried to add c:\external manually to the PATH and reboot but same errors appears.
Thank you for reading, i hope someone can help.
( sorry for grammar or spelling errors! ( i'm italian..))
Nicola
Try dropping all of the external .NET dll's into the bin directory of your website.
When you add a reference in Visual Studio to a separate library or project, it will generally copy the DLL's from that project into your web site's BIN directory, but it won't always grab the DLL files that that project depends on.
So if: yourwebsite.dll --> helper.dll --> helperComponent.dll --> widget.dll (where --> is a reference), when you build only helper.dll ends up in the bin directory alongside yourwebsite.dll. You generally want to get all of them in the same place. Then you shouldn't have to worry about your path or any of that stuff.
Alternatively, if all of those assemblies are strongly named, you can add them to the global assembly cache using gacutil and reference them by their identifier instead of the file.
This was a pretty good read about project organization. The section on 'Copy Local' plays into this. You can setup an xcopy in your Post Build events to put those 2nd and 3rd level references in the bin directory below your solution file.
http://www.simple-talk.com/dotnet/.net-framework/partitioning-your-code-base-through-.net-assemblies-and-visual-studio-projects/