ASP.Net Compilation Conflict… My usercontrol exist

2019-08-27 16:01发布

问题:

I get the following error message trying to run my page

Compiler Error Message: CS0433: The type 'usercontrols_BirthDetails' exists in both 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5c377e82\1f883022\App_Web_ub0hcxgl.dll' and 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5c377e82\1f883022\App_Web_3ndqr5wn.dll'

The code works okay on my machine, and fails on the server as above.

Sometimes this happens on my machine, but I can fix it by closing visual studio and re-starting it. So I guess it's some conflict that happens due to some compilation mistake that ASP.Net is making.

My question is, how can I fix this on my server without rebooting it.

回答1:

I've had this happen on my dev machine a number of times, but I've never known it to happen on a server. And, I'm a coder, not a sys admin, so take what I say with a grain of salt, but . . .

Stop the IIS process, and delete everything under the Temporary ASP.NET files\root\ directory. That's just the place where your .aspx pages get compiled down - this isn't as scary as it sounds. Restart IIS and all should be good. And, if it's not, remember, it's not my fault - you're the one who took advice from a stranger on StackOverflow :-).



回答2:

Well, I did solve the problem, but the root cause was something else... Apparently it had something to do with declaring a variable of my usercontrol's type. For some reason this wasn't agreeing with ASP.Net on the server (though it was well-digested on my own machine)... I don't have any idea why exactly this was happening but this clue is a signal to Jon Skeet to step in and describe the thing in technical mumbo-jumbo.

The solution in my case was to remove the usercontrol variable declaration. I got by with a workaround.



回答3:

I found the same problem in a website that I took over here.

The name of a UserControl was defined multiple times in a partial class.

For example:

UC1.ascx -> public partial class UC1

UC2.ascx -> public partial class UC1

I corrected the name of the partial class for the second user control, and the publish worked.