Access is denied when loading assembly in new domain

  • Thread starter Thread starter Casper Hornstrup
  • Start date Start date
C

Casper Hornstrup

I try to load an assembly in a new domain, but I get an FileLoadException.
I've given all rights to Everyone on the bin directory and below. What could
I be missing?

Relevant code:

Loader loader = new Loader();
loader.LoadAssembly(@"c:\inetpub\wwwroot\ch\ObjectTree\ObjectTreeWS\bin\Demo
1.dll");

Constructor for Loader class:

public Loader()
{
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
setup.PrivateBinPath = "bin";
setup.ApplicationName = "ObjectTree backend";

appDomain = AppDomain.CreateDomain("ObjectTree backend", null, setup);

remoteLoader = (RemoteLoader)appDomain.CreateInstanceAndUnwrap(
"Demo1",
"ObjectTreeWS.RemoteLoader");
}



System.IO.FileLoadException: Access is denied: 'Demo1'.
File name: "Demo1"

Server stack trace:
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String
codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean
throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
Boolean stringized, Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName,
Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args,
CultureInfo culture, Object[] activationAttributes, Evidence securityInfo,
StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String
typeName)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(Met
hodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean
fExecuteInContext, Object[]& outArgs)
at
System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessa
ge msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String
typeName)
at ObjectTreeWS.Loader..ctor(String pluginDirectory) in
c:\inetpub\wwwroot\ch\objecttree\objecttreews\loader.cs:line 35
at ObjectTreeWS.ObjectTree.LoadBackend() in
c:\inetpub\wwwroot\ch\objecttree\objecttreews\objecttree.asmx.cs:line 122
at ObjectTreeWS.ObjectTree..ctor() in
c:\inetpub\wwwroot\ch\objecttree\objecttreews\objecttree.asmx.cs:line 50

=== Pre-bind state information ===
LOG: DisplayName = Demo1
(Partial)
LOG: Appbase = C:/Inetpub/wwwroot/ch/ObjectTree/ObjectTreeWS
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Application configuration file does not exist.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: Demo1
LOG: Attempting download of new URL
file:///C:/Inetpub/wwwroot/ch/ObjectTree/ObjectTreeWS/Demo1.DLL.
LOG: Attempting download of new URL
file:///C:/Inetpub/wwwroot/ch/ObjectTree/ObjectTreeWS/Demo1/Demo1.DLL.
LOG: Attempting download of new URL
file:///C:/Inetpub/wwwroot/ch/ObjectTree/ObjectTreeWS/bin/Demo1.DLL.
LOG: Policy not being applied to reference at this time (private, custom,
partial, or location-based assembly bind).
LOG: Post-policy reference: Demo1, Version=1.0.1423.24764, Culture=neutral,
PublicKeyToken=null
 
Back
Top