Powered by Blogger.

Monday, April 7, 2014

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' error in Asp.Net

Recently I got the below exception after deploy my code to a different server.

Exception information:
    Exception type: TypeLoadException
    Exception message: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Also you can check out:

- Remove column from datatable in Asp.Net

- Simple JavaScript textbox validation example in Asp.Net

- Advantages of WCF in Asp.Net

The error came to me in the below scenario:

We have build the code in .Net framework 4.5 version and also in that we have used Microsoft Enterprise Library 6 as well as Ajax updated version. But the server we deployed does not have 4.5 rather than 4.0.

So we changed the target version as 4.0 in the web.config. But it did not work. Then we compiled the whole project again in 4.0 and then put in the server. But still it did not work.

Then best and only one solution we got is install .Net Framework 4.5 in the server.

And it work for us.