2007年7月25日

[ASP.Net] CS0433 Error

When deplpying ASP.Net web site, you might get a CS0433 error with the following message:

Type [TypeName] already exists in both %ASP.Net Temp Folder%\[AssemblyName.dll] and %ASP.Net Temp Folder%\[AssemblyName.dll]%

This is confirmed a well known bug in ASP.Net.

The reason you got this error is that some of your ASP.Net pages/controls are cross referenced.
Say we have a ASP.Net web application with the following file structure:


AppRoot\Dir_a\PageA.aspx
AppRoot\Dir_a\ControlA.ascx
AppRoot\Dir_b\PageB.aspx
AppRoot\Dir_b\ControlB.ascx

If in PageA.aspx references ControlB.ascx in folder Dir_b, and PageB.aspx references ControlA.ascx in folder Dir_a then CS0433 error well be reported.

There are 2 ways to avoid this kind of error, one is to re-structure your file structure to prevent the cross reference. The other one is to add the following configuration setting in your web.config:

<configuration>
<system.web>
<compilation batch="false">
...


The reason we have to disable batch compilation is that when batch compile is enabled (ASP.Net default), ASP.Net compile each folder to an individual dll. So in our case, Dir_A/Dir_B will be compiled into 2 dlls, and it's clearly that they do cross reference.

沒有留言:

Blog Archive

About Me