Duplicate class from Web deployment project output

Last post 06-15-2009 1:09 PM by richhollis. 4 replies.

Sort Posts:

  • Duplicate class from Web deployment project output

    06-12-2009, 12:23 PM
    • Member
      7 point Member
    • richhollis
    • Member since 01-12-2007, 5:50 AM
    • Posts 19

    I've got a weird problem with my Web deployment project - I have one class name (from web form code behind class) that appears in both the original web application dll and also the web deployment assembly dll that gets generated.

    The web application compiles first and generates its main dll file and then the web deployment project runs and this also generates a dll file.  Everything in the release build of the site works fine apart from one page - it complains of "The type 'MyNameSpace.classname' exists in both..."  This is the page where the duplicate class name problem exists.  For some strange reason I have the same class name in the main web application dll and also the dll file that gets created by the Web deployment project - I have verified this by using Reflector.  I can see the class reference in both.  There is only this class reference in the web deployment project and a reference to global_asax - apart from that it seems like nothing else in the file.

    I have "Merge all outputs into a single assembly" and "Treat as library component" checked.

    The web deployment project DLL seems almost redundant, but removing it breaks the site. 

    Any idea what is causing this problem?  Nothing during the build reports failure and its just this one page strangely - I can't find any reason or anything special about this class that would cause this.  This is just a regular web form page with code behind class, in the default project namespace. I searched the whole project for the class name and it only comes back with the one place on the website where it resides, no duplicates from what I can see in the project.

    Are web deployment projects compatible with web application projects? I upgraded my old website project type to web application, so not sure if web deployment project still valid?

    Cheers

  • Re: Duplicate class from Web deployment project output

    06-12-2009, 1:39 PM
    • Star
      10,710 point Star
    • chintanpshah
    • Member since 11-19-2008, 5:39 AM
    • Ahmedabad
    • Posts 1,905

    richhollis:
    web application dll and also the web deployment assembly dll
     

    What do you mean by this?

    Use Web Deployment Project for VS 2005 and Web Deployment Project 2008.

    This will generated single DLL for whole application.

    Hope this helps...

    Don't forget to mark as answer, if it helps
  • Re: Duplicate class from Web deployment project output

    06-13-2009, 2:53 PM
    • Member
      7 point Member
    • richhollis
    • Member since 01-12-2007, 5:50 AM
    • Posts 19

    Thanks for your reply.

    The problem I have is that the web deployment project is creating its own Dll but duplicating a class inside it when that class already exists from the compilation of the web application project.

    Nothing leads me to believe that I cannot use a web deployment project with VS2008 and a web application project, as this excert from ScottGus blog suggests: Web Deployment projects can be used with either the "ASP.NET Web Site" or "ASP.NET Web Application Project" options built-into VS 2008, and provide a few additional build, packaging and deployment options for you to use.  You can read an old tutorial post of mine here to learn more about they work.

    Does anyone have any idea why I'm getting this class duplication in the web deployment dll?

  • Re: Duplicate class from Web deployment project output

    06-13-2009, 4:33 PM
    Answer
    • Contributor
      3,389 point Contributor
    • hongping
    • Member since 11-02-2006, 9:42 PM
    • Posts 633

    Perhaps there were some things that did not get converted correctly when you changed a web site to a web application project (WAP). Does your page use the CodeFile or CodeBehind attribute? Does the Inherit attribute match what you have in the .aspx.cs file?

    You could try creating a new default WAP, then add a Web Deployment Project (WDP), and then build the WDP. This should work. Then try examining what is different between this WAP+WDP that works fine and your WAP.

    ==============================================
    If you get the answer to your question, please mark it as the answer.
  • Re: Duplicate class from Web deployment project output

    06-15-2009, 1:09 PM
    • Member
      7 point Member
    • richhollis
    • Member since 01-12-2007, 5:50 AM
    • Posts 19

    Hey Hongping

    Good call - for some reason this page had both a CodeFile and CodeBehind attribute.  Once I removed the CodeFile attribute and recompiled the problem is resolved.

    Thanks so much for posting the solution. Very much appreciated.

Page 1 of 1 (5 items)