Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.TypeLoadException: Could not load type from assembly

Tags:

asp.net

Today I've started having this annoying issue while trying to run my web application.

The scenario is as follows:

I have a Web Application Project (WAP from now on) and 4 Library Projects (BusinessEntities, BusinessLogic, DataAccess and Utils).

DataAccess references BusinessEntities BusinessLogic references BusinessEntities and DataAccess The WAP references BusinessLogic, BusinessEntities and DataAccess

When I run the WAP I get:

System.TypeLoadException: Could not load type 'Namespace.DataAccess.ClassDataAccess' from assembly 'DataAccessAssembly', Version=1.0.3551.29465, Culture=neutral, PublicKeyToken=null'.

This is when a method from BusinessLogic tries to create an isntance of a DataAccess class. I use reflector on the DataAccess dll inside de bin folder of the WAP and it does contain the class I'm calling.

I've already tried deleting temporary asp.net file but without success, I'm using Cassini as web server (did not tried IIS yet)

Thanks.

like image 921
Paleta Avatar asked Jan 23 '23 04:01

Paleta


2 Answers

You can also use a tool that comes with the SDK called fuslogvw.exe (Assembly Binding Log Viewer). It is useful for finding assembly binding errors and explains why the error occurred.

like image 85
Michael Mann Avatar answered Jan 25 '23 18:01

Michael Mann


It's likely that you've got some mixed up version numbers in your references.

Check your project references, your web.config file and your .dll versions to make sure that all your references are correct.

like image 39
womp Avatar answered Jan 25 '23 17:01

womp