Friday, November 28, 2014

Could not load file or assembly 'MySQL.Data' or one of its dependencies. Access is denied.



It is very common error with .net assemblies. When someone included dlls from outside, in the project, this kind of exceptions are generic.

Here is the resolution.
  1. Open the file location (MySql.Data.dll in this case)
  2. Right click on dll and check its properties (it should not be encrypted and should have right access permissions)
  3. Run the project after assigning appropriate permissions. It should work now.


Even after this if it does not work. Check in web.config that assembly information is added under <compilation> tag.

It is advisable to included new dlls using nuget package reference. It will update its reference automatically.

Happy Coding!!!