File permissions to delete own on-the-fly-generated assembly files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I haven't done anything yet to study the securiy subject.
I'm developing a product where I will have to learn a lot about security in
..NET applications but for now I have a "simple" isolated problem:

In my main component I'm building some assemblies on-the-fly. I'm loading
them in a seperate application domain and I have to be able to unload the
files and delete them again.
The main component can be used by different client applications.

I'm getting an UnauthorizedAccessException: "Access to the path 'xxxxx.dll'
is denied" when trying to delete one of the generated dll-files.

If anyone ca help me solve this immediate problem it would be much
appreciated.

I'm also interested in any hints or links to good information / literature
about the subject (security in managed code).

Cheers, Jan.
 
Could u demonstrate how do u load and unload you dll in appDomain?

It seems that your dll besides loading into separate domain was loaded into
default domain. That's why u can't delete you dll despite unloading domain -
it has reference in the default domain.

--
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Thanks Michael.

I was completely aware of that possibility but ignored it totally because I
thought I had done it right.

The problem was that my method that compiles the assembly returns the
assembly reference. The calling method didn't use the reference to anything
but check if it's not null.

I changed my compile-method to return a boolean (errors.Count == 0).

I really didn't think that returning the assembly reference was enough to
provoke the loading.

But thanks for making me check that.

Regards,
Jan
 

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

Back
Top