load assembly from different folder

P

peter.drienovsky

Hello,

let me describe my problem:


ENVIRONMENT:
..Net 2.0, MSVS 2005, c#, WinXP

SYMPTOMS:
If assembly 'AgentDesktop' IS NOT in the (loading) application folder,
Assembly.Load(AssemblyName) throws FileLoadException with Message:

"Could not load file or assembly 'AgentDesktop,
Version=1.10.2573.22044, Culture=neutral, PublicKeyToken=null' or one
of its dependencies. Access is denied.":"AgentDesktop,
Version=1.10.2573.22044, Culture=neutral, PublicKeyToken=null"

If assembly 'AgentDesktop' IS in the (loading) application folder,
Assembly.Load(AssemblyName) proceeds correctly.


ADITIONAL INFORMATION:
Q: Do I have AssemblyName.CodeBase set to the folder containing
'AgentDesktop' assembly?
A: Yes I do.

Q: Am I really sure 'AgentDesktop' assembly is in that folder?
A: Yes, I am. Moreover, othervise exception thrown would have been
FileNotFoundException and not FileLoadException according msdn
definition of FileLoadException article
http://msdn.microsoft.com/library/d.../frlrfsystemiofileloadexceptionclasstopic.asp
: "The exception that is thrown when a managed assembly is found but
cannot be loaded."


Q. Have I added folder containing 'AgentDesktop' assembly into the
AppDomain.CurrentDomain.SetupInformation.PrivateBinPath calling
AppDomain.CurrentDomain.AppendPrivatePath()?
A: Yes I have.

Q: Have I used suggestions from Suzanne Cook's article 'Debugging
Assembly Loading Failures' recommended in another topic targeting this
issue:
http://blogs.gotdotnet.com/suzcook/archive/2003/05/29/57120.aspx,
section 'For FileLoadException', paragraph 'For an "Access is denied"
message...'?
A:Yes I Have. None process had the file locked and without share-read
access. User under which the loading process run had full control over
the folder containing 'Agent Desktop' assembly.


I suppose this problem is somehow conected with code security issues of
..Net, however I'm not familiar with this domain. At this point I want
to ask you for help.

Many Thanks

Peter Drienovsky
 
C

Chris Dunaway

Q. Have I added folder containing 'AgentDesktop' assembly into the
AppDomain.CurrentDomain.SetupInformation.PrivateBinPath calling
AppDomain.CurrentDomain.AppendPrivatePath()?
A: Yes I have.

The only thought I had, which you have probably already considered, is
that the folder you use with AppendPrivatePath must be a child folder
of the application folder to work IIRC. I might be mistaken about
this, however.

Chris
 
P

peter.drienovsky

Hi Chris,

you are right. If assembly being loaded is in childfolder of main app
and this folder is specified in PrivateBinPath of current AppDomain,
then assembly is loaded. Helpful information as it offers some
alternatives to my original problem. Thanks.

Hovewer, I am still wondering whether one could load assemly at runtime
from arbitrary folder.
Does somebody know answer?

P.

Chris Dunaway napísal(a):
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top