locked
The type '<class>' exists in both '<dll location>' and '<dll location 2>' RRS feed

  • Question

  • User-749216012 posted
    For some reason though it appears that one of my class files (_common.cs - in the App_Code directory) is being included in the WAP .dll file as well as when it compiles the App_Code at runtime.

    error CS0433: The type 'inlinehockey._common' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\25321638\9b5c4b00\assembly\dl3\3657f4e6\cd91aef5_4d5cc601\inlinehockey.DLL' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\25321638\9b5c4b00\App_Code.xad_ajc1.dll' 


    The error was not knowing what dll to use for the type when you get the CS0433 error.

    How can I get round this error?

    Thanks
    Jeremy Thake
    www.made4the.net
    Sunday, April 9, 2006 11:31 PM

All replies

  • User-1634877164 posted

    With WAP projects you want to make sure that you don't use a app_code directory, since classes within that directory will indeed get compiled twice (once in the code-behind and once at runtime) unless you explictly exclude the file from WAP project.  Try renaming the app_code directory to something else to fix it.

    BTW - this tutorial walksthrough how to migrate an existing VS 2005 Web Site Project to a VS 2005 Web Application Project: http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx

    Hope this helps,

    Scott

    Monday, April 10, 2006 12:49 AM
  • User-749216012 posted
    Thanks for the link, and for your time in helping me to fix this.

    Keep up the amazing work!

    Jeremy
    Monday, April 10, 2006 1:59 AM
  • User791135089 posted

    I want to document for the posterity that one could get this error even if you don't have an App_Code directory but if all of the following is true:

    * You are using a Web Applications Project. (Perhaps you migrated from 1.1 like I did.)

    * You are also using a Web Deployment Project.

    * You have a "CodeFile" page directive in the some page markup instead of "CodeBehind". (How? I don't know. Could be because of certain migration issues between 1.1 and 2.0. )

    In this scenario, when MSBuild compiles the wdproj file, it compiles this page into the <Project>_deploy.dll in addition to the regular <Project>.dll. This results in duplicate class names and hence the runtime error.

    Friday, July 20, 2007 5:09 PM
  • User-1695214467 posted

    I got this message due to the fact that I had a user control firing an event that was being handled in the parent page.

    I moved the delegate and event arg definitions into a seperate file and it solved the problem.

    Friday, February 1, 2008 6:20 AM
  • User1992410573 posted

    I got this from having two referneces to the same dll. I included the dll by file name once (Browse tab), and then again via the project (Projects tab) that produced the dll. Removed one of the references and all was well.

    Wednesday, February 13, 2008 5:18 PM
  • User-1968810289 posted

    thanks tomtyf......

    I moved the delegate and event arg definitions into a seperate file and it solved the problem.

    * crazy! 

    Tuesday, March 11, 2008 12:53 PM
  • User1995298690 posted

    * You have a "CodeFile" page directive in the some page markup instead of "CodeBehind". (How? I don't know. Could be because of certain migration issues between 1.1 and 2.0. )

     This was the problem for me.  Actually, to be more specific, it was that I had BOTH a "CodeBehind" directive and a "CodeFile" directive in my page.  As an added bit of information, I was in the process of "globalizing" this particular application and I had recently used the "Generate Local Resource" tool (off the Tools menu).

     Perhaps it was in that process that the mysterious "CodeFile" directive showed up.  Anyway, now it's working and I'm happy.  Thank you piyushnaik!

    Tuesday, October 14, 2008 5:18 PM
  • User1094068975 posted
    Thanks so much, tomtyf! The event handler been realy the key for me. I have a user control, that is very simple. It has a dropdown inside, and I provide SelectedIndexChanged event with the folowing way.
     
     public event EventHandler SelectedIndexChanged;
            protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (SelectedIndexChanged != null)
                {
                    SelectedIndexChanged(sender, e);
                }
            }
      I've started getting this 'The type '<CLASS>' exists in both '<DLL location>' and '<DLL location 2>'' error from time to time. After I've commented this code the problem gone. This is definitly strange. By the way I'm using .net 3.5 sp1 and I don't use App_Code folder at all. This error been happening on ASP.NET development server, and after I publish it on IIS 7 and IIS 6.
    Wednesday, February 4, 2009 12:47 AM
  • User-1439576955 posted

    Thank you for your help. I changed "CiodeFile" to "CodeBehind" in my ".aspx" file and it took care of my problem.

    Mike1298

    Friday, April 10, 2009 2:49 AM
  • User654334663 posted

    hi

     when i want to publish website in vs 2005

    i am getting the below one's

    Error    1          e:\SMSPROD\DotnetCode\Registration.aspx(61): error CS0433: The type 'DotnetCode_usercontrols_Email' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_53uqcplx.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_aruiysdi.dll'            E:\SMSPROD\DotnetCode\Attendence\AttendenceMonthly.aspx         1         

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    Error    14        The type 'DotnetCode_usercontrols_Email' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_53uqcplx.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_aruiysdi.dll'       E:\SMSPROD\DotnetCode\Registration.aspx   61       

    try to fix these issues

    Regards

    Koti

    Monday, June 1, 2009 10:09 AM
  • User654334663 posted

    hi

     when i want to publish website in vs 2005

    i am getting the below one's

    Error    1          e:\SMSPROD\DotnetCode\Registration.aspx(61): error CS0433: The type 'DotnetCode_usercontrols_Email' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_53uqcplx.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_aruiysdi.dll'            E:\SMSPROD\DotnetCode\Attendence\AttendenceMonthly.aspx         1         

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    Error    14        The type 'DotnetCode_usercontrols_Email' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_53uqcplx.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\smsprod\a3b2710a\74e825fa\App_Web_aruiysdi.dll'       E:\SMSPROD\DotnetCode\Registration.aspx   61       

    try to fix these issues

    Regards

    Koti

    Monday, June 1, 2009 10:13 AM
  • User1031342864 posted

     I had the same issue.  I had actually somehow got a copy of my Class.cs file in the Properties folder of another project.  Not sure how it happened, but most likely a drag and drop mishap, or a cut and paste mishap.  Once that was removed, all was well.

    Tuesday, July 14, 2009 8:57 AM
  • User1959525172 posted

     I also had this problem. In my case I had an extra reference in the Compilation>assemblies bit of my web.config file. Just removed the reference and it solved the problem.

    The following link is suggested this fix to me http://dotnetfish.blogspot.com/2007/09/type-xxx-exists-in-both.html

    Friday, July 31, 2009 5:16 AM
  • User-1088272094 posted

    Thank you for documenting this, it was my problem and your tip saved me a lot of time.

    Tuesday, August 18, 2009 9:49 PM
  • User-1475498740 posted

    Well, I may throw yet another answer to this error.  I don't think this is quite the same as others, but similar.  I unfortunately named my Master page the same as an ASPX file that I had in the project.  This caused them both to have the same class name.  I renamed the master page (and class name within the master page) and all references to it in any other file and that took care of it for me.   Thanks for all the suggestions though that led me in the right direction.

    Friday, November 20, 2009 11:43 AM
  • User-1463062036 posted

    The problem for me was that I had both CodeBehind and Src in my Page directive.

    Thank you.


    Wednesday, November 25, 2009 2:12 AM
  • User1227534902 posted

    This could happen due to several reasons. I've had the same experience getting this error. We need to be very carefull when using name for classes and renaming them. It's best to check inheriting class is same as the page name. Also when declairing IDs for controls it's better to have unique names. Otherwise you get so many duplicates and this will result in creating duplicate DLLs at pre-compile destination. When you run the precompiled site system gets confused to pick which class to use during execution. Best option is to do a class diagram for bigger projects before start developments. Also create a class library for generic methods without creating classes within the site.

    Wednesday, February 17, 2010 7:46 AM
  • User44553148 posted

    The issue for me came up when I copied a page.  I pasted it back into the project under a new name.  The code behind contained the original class name and did not rename the partial class to the new page name.  The code behind also retained the original class name.  This created within the same namespace two classes with the same name.  This caused the conflict for me.  I changed the Inherits attribute of the  Control directive (using Master pages) to what should have been the new code behind class name, as well as changing the class name in the code behind partial class to match the corrected control directive. 

    Monday, March 15, 2010 10:15 AM
  • User-636527355 posted

    Hi, I wanna thank you all for your tips in this forum, they helped me a lot to put me in the right direction.

    In my case, I was working on an application with crystal reports with a previous version than the one I have installed on my computer. So I upgraded my reports to the new version and I added all the necesary references in my project but still I kept getting this error message:

    Compiler Error Message: CS0433: The type 'CrystalReportViewer1' exists in both
    'c:\Windows\assembly\GAC_MSIL\CrystalDecisions.Web\12.0.2000.0__692fbea5521e1304\CrystalDecisions.Web.dll'
    and 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2ebdf82e\3c9141dd\assembly\dl3\6944af87\041a486d_92c0ca01\CrystalDecisions.Web.dll'


    So, I opened in notepad the file CrystalDecisions.Web.dll from the location c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2ebdf82e\3c9141dd\assembly\dl3\6944af87\041a486d_92c0ca01\ and i realized that the version it had was the previous version of crystal (I looked for the version through all the weird characters in the file). Then I looked for the file that i was adding in my project references (in C:\Program Files\Business Objects\Common\4.0\managed\dotnet2\CrystalDecisions.Web.dll), I copied this file and replaced it in my location c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2ebdf82e\3c9141dd\assembly\dl3\6944af87\041a486d_92c0ca01\

     

    After that I compiled my project and executed the page where I have my report and it worked find.

     

    I hope this information help anybody.

     

    Best regards Smile

     

     

    Monday, March 15, 2010 2:15 PM
  • User303805040 posted

    In my case, I actually had two different aspx pages referencing the same class. I copied the old class and forgot to rename it in the new aspx and aspx.cs files.  Not sure why this was not caught when I was using the VS development server and only showed up when I was publishing to a remote site.  ANyway, I changed the new class name to the name of the new aspx file and the error cleared.  I guess this eror can show up in many different ways..... :-( 

    Saturday, April 3, 2010 12:18 PM
  • User448266513 posted

    in my case its not working at all... i am using a normal website, i cannot build pages and publish dlls so i have to settle with regular aspx.cs files, when i publish few files i get this error regarding one control, few minutes later, refresh, and it works fine... sometimes it takes half an hour before it goes back to normal, i am CLUELESS to what i can do to prevent it

    i used namespaces to set them apart, but it seems like totally random! 

    Wednesday, April 28, 2010 9:11 PM
  • User1062291411 posted

    I had the exact same problem.

    It seems the WAP was made with both App_Code and CodeFile but not for the same objects. (that is, I did not found any of the causes described above...)

    So far I've been able to make things work again by forcing IIS to recompile the files in question (by changing them, might try to find a better way of doing that...)

    I think perhaps somehow the temp dll-files might have been copied from an other version of the same system or something along that line.

    HTH

    /Erik

    Monday, November 1, 2010 6:21 AM
  • User602856693 posted

    This error is kiling me. I have been trying every recommended solution I can find and to no avail.

     Essentially I have created a custom user control and registered it to the page via:

    <%@ Register TagPrefix="ecc" Namespace="Evolve.CustomControls" %>

     
    I have created a class for the control and verified the uniqueness of the name. 
    I have even seperated it out in it's own namespace.
    I have deleted the temp folders previous forms suggest 
    I have tried it inside the App_Code as well as out. 
    I am using VS2010 C#.Net, WAP, Codebehind for all files
    I just can't figure this out. Any help with this would be greatly appreciated!
    Friday, December 24, 2010 5:02 PM
  • User-1492674711 posted

    I checked source safe and found I had mistakenly not deleted an extra file (a copy of the aspx with the compilation problem).

    I deleted the extra file, and the problem is gone.

    Wednesday, December 29, 2010 2:08 AM