ASP.NET 2.0 Inherits Duplication Inspector Utility

In the new 2.0 web application model, every web page (.aspx) and it’s code behind (the class that this page “Inherits” from, actually it’s partial with it, but that’s the property name) compiles into a single assembly. At least as a default behavior.



That means that the following relationship is completely valid in this compilation model:

Default.aspx (CodeFile=Default.aspx.cs, Inherits=MyNamesapce.MyDefaultPage)
   Default.aspx.cs (class name MyNamespace.MyDefaultPage)

Default2.aspx (CodeFile=Default2.aspx.cs, Inherits=MyNamesapce.MyDefaultPage) // Inherits: same as above
   Default2.aspx.cs (class name MyNamespace.MyDefaultPage// class name: same as above

This can be quite confusing though. While you’re developing everything will work as expected as every .aspx & aspx.cs will compile to a different assembly so no collision will occur; So you think you’re good to go…

The problems start to show up when you’re trying to compile everything to a single assembly (production env.). Now you’ll get an “aspnet_merge.exe” error which tells you that you can’t combine (1) Default.aspx with (2) Default2.aspx and (3) MyNamespace.MyDefaultPage class. It makes sense, after all, those three are partial classes.

When can this happen ?

if you Copy-Paste an existing page & forget to change the name of the class in the CodeBehind and in the Inherits property.

Solution – How to check if you’re really good to go:

I’ve written a small utility with Mario, my teammate, which will find this duplication and give you a little report telling ya if you have more than 1 aspx file which inherit from the same class. Running it on the example above will produce the following report:


Now all I have to do is change the Default.aspx.cs class name and change the Inherits property name in Default.aspx.

How to use the “Duplication Inspector” utility ?

(1) Extract the zip file (down below).
(2) Open app.config and change the “WebDirectoryToInspect” as needed.
(3) Run the InheritsDuplicationInspector.exe and voila !

You can find the source files here: – 47 KB

Have fun.


Damn, I love Add-ins !

Hey y’all,

I can’t seem to stop, those add-ins bastards are too addictive !
Oh well, here are more great VS.NET add-ins you should all check them out:

  1. GhostDoc – This great utility will able you to “auto” document your methods\properties with a single mouse click.
  2. WhidbeyCommands 2 – Just read the man’s post :) TIP: if you give presentations while using the VS.NET, you MUST download this baby (check out “Demo font” option) !
  3. HandleWhiteSpace – Clean your files from unnecessary white spaces.



Another two great tools to work with.

As you aware by now, I’m kind of programming-gadgets freak. After sharing with you the magic of SlickRun I thought it will be nice (of you to listen, I’m gonna write it anyway) to recommend about another two tools.

  • Visual XPath – After reading Justin’s recommendation about it I thought to give it a try. In my every day work I’m handling a lot of xml, mostly via XmlHttp or sophisticated client side-work (like dependable DropDownLists, custom validations, building dynamic html) and this tool just give you great ability to test XPath phrases with no effort and nice GUI (always important). 


  • VSTabs – My second recommended tool is actually an add-in for Visual Studio .NET; The greatest value of this add-in IMHO is the file wrapping tab. It “smart” enough to wrap your .aspx file with it’s .cs file and put them all in one tab. Well, one image is better than 1000 words so –




        As you can see, it’s wrapping all the linked files in one tab which is great if like to be organized,

        or you’re one of those fellows, like me, that sometimes getting lost if I have

        MyFile.aspx at the beginning of the tabs scrollbar and MyFile.aspx.cs at the end if it.


If you have some add-ins to share with me – bring it on !