7

I'm having this weird problem with IIS 7 on Windows 7, where it can't load a dll I'm using. However, it seems to only happen after a while; it works fine for some random amount of time until it starts throwing this message:

Could not load file or assembly 'Mono.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. Access is denied.

If I delete the dll and re-add it, it works fine for another length of time, and later stops working again. This is happening in both an asp.net webpage as well as a web service, however in a normal .net desktop program it works fine.

This only happens with Mono.Security, not with any other dll I'm using (I'm using Npgsql which is dependent on Mono.Security).

If anyone could offer some insight into this, it would be great.

jli
  • 6,523
  • 2
  • 29
  • 37

2 Answers2

5

Check file permissions on the DLL file / folder, to make sure your ASP.NET AppPool account can access the file.

Make sure the file's permissions don't inherit from parent - something might be resetting these.

Leon
  • 3,311
  • 23
  • 20
  • The thing is, it works fine for a while, then randomly stops working. The permissions still look fine at that point. Also, just for testing my ASP.NET is currently running on my user account, which owns the file... – jli Aug 18 '11 at 17:42
  • 2
    If you grant "Everyone" read/execute access to the file/folder, does that make the issue go away? – Leon Aug 18 '11 at 18:56
  • See if this helps... http://blogs.msdn.com/b/sayanghosh/archive/2007/04/21/solution-to-could-not-load-file-or-assembly-or-one-of-its-dependencies-access-is-denied.aspx – Leon Aug 18 '11 at 18:59
  • I _think_ the everyone thing did the trick! For that help I'm using your answer as the accepted. – jli Aug 18 '11 at 19:08
  • @Leon my problem was that the dll had perms from it's parent, I remove them and Voila ! it is working now ... – franko_camron Apr 11 '12 at 23:36
0

Perhaps you are performing a backup during those times? Just a shot in the dark... Also, in your web.config you don't need to define the version, culture, or public key in order to use the assembly.. Maybe that has something to do with it.

cgcarter1
  • 327
  • 1
  • 8
  • Hmm.. no backups are being done so I guess thats not it. I didn't add it to the web.config file directly, I added the DLL as a reference in VS so I'm somehow doubting the version/culture/pk are the issue, but I suppose its possible. – jli Aug 18 '11 at 17:44
  • This looks a lot like what you are facing... Couldn't hurt to try: http://blogs.msdn.com/b/sayanghosh/archive/2007/04/21/solution-to-could-not-load-file-or-assembly-or-one-of-its-dependencies-access-is-denied.aspx – cgcarter1 Aug 19 '11 at 11:50