By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,293 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

Loading private assemblies from a subdirectory

P: n/a
Hi all!

I'm writing a winforms test harness which lets me specify a subfolder
from which to load a particular .net assembly dll. The idea is that
there will be multiple subfolders, each having this dll.

To ensure that there are no conflicts with similarly named assembly dll
files, I'm am trying to load a subdirectory's dll into its own
AppDomain. However when I call the
AppDomain.CreateInstanceFromAndUnwrap method, it throws an exception,
saying "File or assembly name ImportController.dll, or one of its
dependencies, was not found"

Let me be more specific by giving you some code-snippets....


This is where I'm trying to create a new AppDomain. 'subfolder' is a
subfolder name (not full path) of the directory where the test harness
exe resides. exePath is the directory of the test harness exe.
ImportController.dll is the .NET assembly dll which I know resides in
the subfolder
Client.ImportController.ImportControl is a type defined in that
The subfolder not only contains ImportController.dll, but also the
other dlls it references
AppDomainSetup setup = new AppDomainSetup();
string exePath =
Path.GetDirectoryName(Assembly.GetEntryAssembly(). Location);
setup.ApplicationBase = exePath;
setup.PrivateBinPath = subfolder;
AppDomain appDomain = AppDomain.CreateDomain(subfolder, null, setup);
object ic =
appDomain.CreateInstanceFromAndUnwrap("ImportContr oller.dll",


When I run this up, I get an exception...its message being "File or
assembly name ImportController.dll, or one of its dependencies, was not

This is what I see in the Assembly Binder Log Entry


*** Assembly Binder Log Entry (4/7/2006 @ 7:08:43 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file

Assembly manager loaded from:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusio n.dll
Running under executable
D:\Project\Client\Import\TestHarness\bin\Debug\Tes tHarness.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: Where-ref bind. Location =
D:\Project\Client\Import\TestHarness\bin\Debug\Imp ortController.dll
LOG: Appbase = D:\Project\Client\Import\TestHarness\bin\Debug
LOG: Initial PrivatePath = Current
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).

LOG: Processing DEVPATH.
LOG: Attempting application configuration file download.
LOG: Download of application configuration file was attempted from
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: Attempting download of new URL
LOG: All probing URLs attempted and failed.


It seems to show that the PrivatePath is set to 'Current' which is the
correct subfolder name, yet it does not try to download the dll from
that location.
I'm probably being a complete dunce, or just haven't properly
understood how AppDomains work, but if you could shed some light on
this situation of mine I would really really appreciate it.

Many thanks in advance....


Apr 7 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.