思想有多远 你就能走多远

诚信为本

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

A few days ago, I spend almost a day figuring out what went wrong with an application I was writing. Apparently a SerializationExeption can occur when executing ASP.NET code in the ASP.NET Development Server (Cassini).

Exception:
Type is not resolved for member ‘Classname,Assembly, Version=1.1.0.31, Culture=neutral, PublicKeyToken=null’.

Exception details:
System.Runtime.Serialization.SerializationException: Type is not resolved for member …

When executing the same website in IIS, everything runs fine.

 

For some strange reason the ASP.NET Development server loads the different assemblies in different ApplicationDomains, resulting in members that cannot be found.

There are different solutions to be found on the web, like inheriting your objects from MarshalByRefObject, but this can have a performance drop.

There is a simpler way in my opinion:
First of all specify the directory containing the assembly in the DEVPATH environment variable.
(Do this by opening the System Properties, properties of My Computer. At the bottom of the Advances tab page, you have a Environment Variables button. Just add the variable to your user only.)
System Properties Environment Variables

Secondly, open the machine.config Normally you’d expect that web.config would do too, but that isn’t the case, it has to be machine.config! (This way, there isn’t any trace of this fix in theproject itself)
Add the following code:

<configuration>
   <runtime>
       <developmentMode developerInstallation=”true”/>
   </runtime>
</configuration>

Save it, restart the ASP.NET Development server(s) and you’re good to go.

Report of the issue.

Note: there is 1 downside, sometimes, the .dll files that Visual Studio generates can get locked by Cassini. Restarting it helps.

posted on 2008-02-16 01:28  Borllor Lee  阅读(4164)  评论(5编辑  收藏  举报