views:

268

answers:

1

I've had this intermittent issue when using asp.net. My site is dynamically compiled. Sometimes when I modify a user control my web site complains that it is defined in multiple places. It almost seems like the old control did not get removed from the asp.net temporary files and the updated control is compiled to the same directory so it's defined in multiple places. That would make sense to me except for the fact that I have no control over what is in the Temporary ASP.net Files folder.

I've read that having circular references will cause this. I've made sure that I don't have circular references. Even with the simplest site I've seen this happen.

I've noticed that when using Master Pages this error seems to come up a lot more frequently.

I've read that a hotfix tries to fix this issue but I've gotten this error after applying the hotfix.

If I get the file causing the issue and make an edit to it then the error goes away. Even if I just put a space in the file it will resolve the error.

I can also get the error to resolve sometimes by visiting other pages of the site that might not use the user control and hitting refresh. This does not always work.

If I set the site to debug the error never happens. If I set it so that it comiles on a page by page basis then the error does not happen as much but still happens.

Below is what the error looks like.

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1595: '_ASP.Header_ascx' is defined in multiple places; using definition from 'C:\WINNT\Microsoft.NET\Framework\v1.0.3705\Temporary ASP.NET Files\root\afwew23d\asdfasd423\asdf23.dll'

Edit: I'm using .net 2.0 (3.5) even though the error above says 1.0. I got that error from another source since I can't reproduce the issue every time. But the type of error is the same.

Edit 2: Thanks gisresearch for your research. There was one statement in the link you provided:

One caution even if you have debug=false, is that if you go in and change something in one of your aspx pages, this page will have to be recompiled, but this doesn’t cause an appdomain reload so the whole application is not batch compiled again. This has the effect that the page will now get recompiled separately and get its own dll, so don’t change your aspx pages on a live server too often.

There is a setting in machine.config determining how many recompiles are allowed before the app domain restarts, by default it is set to 15, so after 15 recompilations the app domain will restart, just as it would if you touched the web.config or touched the bin directory.

This seems to say that when debug=false and the site has already been visited and compiled, if you change a page it will only compile that one page. That sounds like it could cause problems. I had thought changing a page or user control would cause the entire app to recompile.

+1  A: 

Do you have two user controls with the same file name in diferent Folders of your Web App? That sometimes will cause this issue.

If I set the site to debug the error never happens.

when debug=true, the asp.net compiler don’t batch compile, when debug=false it does batch compile and may cause this issue.

The Read this post.

There is a conversation about the same issue.

re: ASP.NET Memory: If your application is in production… then why

is debug=true Monday, April 24, 2006 2:39 PM by Robbie Coleman We did get an error for a UserControl that it reported it could not load the FileName_ascx class due to multiple versions in the Temp ASP.NET folder.

We identified that we had two user controls with the same file name in diferent Folders of the same Web App. The also had diferent namespaces and never through this exception until we set debug="false". We even wiped the Temp ASP.NET directory clean on an IISreset.

The only way we could fix the error, was by renaming the ascx file of one of the two.

Is this correct...? Was there a better way to fix this?

BTW... [KissUpText] Tess, your posts have been very helpfull to our development team, and we really appreciate all the information you have given away. [/KissUpText]

re: ASP.NET Memory: If your application is in production… then why

is debug=true Tuesday, April 25, 2006 1:56 AM by Tess Hi Robbie,

Thanks for the nice comment:)

I am assuming that you are getting "CS1595: 'UserControls.WebUserControl2' is defined in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\usercontrols\293a1a4b\dbb2d387\cisxatg3.dll' " or similar.

The problem basically occurrs if you are using src rather than CodeBehind and your cs or vb files contain a definition for exactly the same class in exactly the same namespace. The error is really the same as what you would get if you tried to compile a dll with another class defined twice in the same namespace.

The reason i am saying it happens when you use src is because if you would use CodeBehind you would have gotten an error at compile time.

If the usercontrols are really the same I would avoid creating a copy, and instead using the one from the other folder. If they are different I would either give the different names if possible, and if not, make sure that the source classes are in different namespaces, such as ProjectName.FolderName.MyUserControl

The reason you are seeing it now and not before is because you are now batch-compiling everything into one dll.

Hope this helps.

J.W.
I forgot to mention that one. Yes, I do have this, but they have different namespaces at the top of the ascx file. For example they might be: Home_AboutUs_Controls_header and Home_Portfolio_Controls_header. I think if they were the same the error would happen every single time.
metanaito
Thank you for your research. The link you provided had an interesting statement I did not know about. I'd like to comment more but not much space here. Please see my question above for what seems like the answer.
metanaito