Showing posts with label ASP.NET. Show all posts
Showing posts with label ASP.NET. Show all posts

Monday, June 23, 2014

IIS Could not load file or assembly 'App_Web_..., Version=0.0.0.0

Message

Could not load file or assembly 'App_Web_..., Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.


Context

Opening an ASP.NET page on a IIS web server.


Explanation

An unhandled exception occurred during the execution of the current web request. Precisely a System.IO.FileNotFoundException. This error may happen when the website is trying to load a custom web control that is displayed as needed. When the framework try to compile it, appends a random string at the end of the assemby. If another control referes to this one, at compile time the name of the newly compiled file and the previous version of the file cause a file name mismatch and therefore the parent control is looking for a file that no longer exists.


Solution

Setting the batch property of the compilation tag to false in the web.config file:

<compilation debug="false" batch="false" />


Monday, February 20, 2012

UnauthorizedAccessException opening UNC path file with FileStream


Message
UnauthorizedAccessException: Access to the path '...' is denied.


Context
Executing the following line of code (C# ASP.NET under Visual Studio, localFile or UNC path)

FileStream fs = new FileStream(fileName, FileMode.Open);

Explanation
ND

Solution
Add the fileaccess mode option "FileAccess.Read":
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);