I\'ve a working XML Web service written in ASP.Net. Now I need to reference certain assemblies lying in a specific folder e.g. c:\\NotMyCode
I do no
You could always use the: AppDomain.CurrentDomain.AssemblyResolve Event and call
Assemly.Load(Path.Combine(@"c:\NotMyStuff",args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"))
See link for more info.
I think you can reference specific assembly paths in code as well.
AppDomain.CurrentDomain.AppendPrivatePath("C:\\NotMyCode");
Doing that in your Global.asax Application_Start should do the trick.
You can put in GAC and access it from there.
According to the MSDN documentation,
Referenced assemblies outside the application's root directory must have strong names and must either be installed in the global assembly cache or specified using the <codeBase>
element.
So, it might appear that you're out of luck. Here's what I'd try:
linkd SharedCode c:\NotMyCode
. This makes <yourappbase>\SharedCode
effectively be an alias for c:\NotMyCode
.SharedCode
. Since this is under your application base, it should work. Alternatively, use AppDomainSetup.PrivateBinPath to set the path probed for assemblies.I'm quite curious to see if this works :-)
You could always put your referenced assemblies in the GAC, then the location would not matter. You can install the component by dragging it into the GAC (C:\windows\assembly) or running GACUtil.exe.
This article may help. It describes the "Best Practices for Assembly Loading."
At first I thought you could used the <probing privatePath="bin\debug"/>
element in the runtime/assemblyBinding in the web.config, but the probing will only allow you to specify subdirectories under the root location.