Thursday 4 June 2009

ASP.Net Quick Tip: Get Web Deployment projects working with Web Application Projects

Hopefully this will save someone else (or my future self) the couple of hours my colleague and I spent wrestling with ASP.Net to get this to work.

We have an ASP.Net 3.5 Web Application project and were trying to pair it up with a Web Deployment Project. This first problem we faced was with ILMerge complaining during the build process for the web deployment project. It said "An error occurred when merging assemblies: ILMerge.Merge: The target assembly 'cwSharp2' lists itself as an external reference.”. We fixed this thanks to a comment by JohnC on a post by Rick Strahl. You have to make sure that the output assembly for the Web Deployment project is different to the Web Application project – we called ours [Project].Pages.

The next problem didn’t reveal itself until we actually tried running the website as compiled by the Web Deployment project. When we tried browsing one of the pages we got errors like “Compiler Error Message: CS0433: The type '**' exists in both '***.dll’ and ‘***.dll'”. I searched, and – bing – out popped the answer: you have to right-click your web application project and click “Convert to Web Application”; doesn’t quite make sense, I know, but it works!

4 comments:

Todd Taylor said...

Thanks for posting this, it helped me out. In my case, what clicking the "Convert to Web Application" command changed the "CodeFile" attribute in the Page directive to "CodeBehind" on my ASPX pages. This made the CS0433 error go away for me.

Unknown said...

Todd,
Glad to be of service!

Anonymous said...

Thanks. Quickly solved my issue!

Jason said...

Thanks, this saved me tons of time, I'm sure.

Post a Comment