Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Thursday, January 3, 2013

Visual Studio Could not load file or assembly bug

Message

Could not load file or assembly ... or one of its dependencies.

Context

Opening a form in Design Mode in Visual Studio 2010

Explanation

The Copy Local property of a referenced DLL appears to be true, but actually it is not set to True in the XML project file.

Looking inside the XML file:

<Reference Include="...">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\C1.Win.C1FlexGrid.4.dll</HintPath>
<Private>True</Private>
</Reference>

We should see a code like this one, but the yellow line "<Private>True</Private>", that is the one corresponding to the Copy Local property value, is missing.

Solution

The line could be manually inserted, but better proceed this way:
  1. Right click on the DLL that is giving the problem.
  2. Set the Copy Local property to False.
  3. Save the projetct
  4. Set the Copy Local property back to True.
  5. Save the project again.
This will cause Visual Studio to add the missing line "<Private>True</Private>".

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);