Three Is It

Because two isn't enough and four is just too many

The people who are trying to make this world worse are not taking a day off. How can I? Light up the darkness.
Bob Marley
Home Blogs Genealogy Brad's Bookshelf Subscriptions Contact Sign in
 

About the author

Brad Butts is a .NET developer and architect. He is married with children and enjoys reading, working out, and genealogy is his five minutes of spare time.
E-mail me Send mail
National Debt Clock

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

aspnet_merge.exe exited with code 1

Pretty descriptive error code, eh?  Well, I was going to put together an example of what aspnet_merge.exe can do, so the first thing I wanted to do was grab an example application, particularly one that makes use app_code files.  I decided to use the code from BlogEngine.NET.

Yes...I know, I know...the BlogEngine.NET code was never designed to live under a WAP-type model, but surely it can live under that model, right?  Well, uh, not without difficulty.

Step 1: Run aspnet_merge and see what happens
So, I used the Visual Studio 2005 Web Deployment Projects to construct a WDPROJ--an MSBuild project with sweet tasks to run the aspnet_merge utility.  (Note: as far as I can tell, BlogEngine.NET is still a Visual Studio 2005 solution)

At the command line, I typed: msbuild BlogEngine.web_deploy.wdproj



The build started and 54 seconds later...blam!  error MSB6006: "aspnet_merge.exe" exited with code 1.

So, what happened?  Sounds like this error happens when class names collide.  Like so many things, the Web Site project tends to let you get away with bad coding practices like using the same class name for a page's code behind in multiple places--so long as the pages are in separate folders.  Aspnet_compiler will compile separate DLLs so there's never the chance that a single assembly will contain two classes of the same name; however, when aspnet_merge tries to merge all the assemblies into one, the class names will clashes and cryptic errors like "error code 1" will get thrown.

Step 2: Figure out where my problems are and fix them
Unfortunately, the default console logging behavior of MSBuild does not tell me where my errors are, so, after consulting with my handy-dandy MSBuild command line reference, I figure I can do something like this to get more detail on where my errors are occuring:

msbuild /nologo /v:diag BlogEngine.web_deploy.wdproj > msbuild.log

Scrolling up from the bottom of my log, I see this error:

An error occurred when merging assemblies: ILMerge.Merge: ERROR!!: Duplicate type 'widgets_LinkList_edit' found in assembly 'App_Web_nbdnprem'.

Ah-ha!  Multiple classes each named widgets_LinkList_edit.  A quick search for that name reveals that, yes, that class name is used for both the edit.ascx code behind of the LinkList and TextBox widgets.  To fix, I'll go to the TextBox's edit.ascx.cs file and change that class name to widgets_TextBox_edit and to the page declaration in the associated ASCX page and update that, as well.

1...2...3...4 error code 1 issues later and it looks like I have a build!  But do I have a good build?

Step 3: Fire up my BE build to see if it works
Seems like the easiest thing to do is to fire up an instance of the ASP.NET Development Server to host my BE build, so I execute this at the command line:

WebDev.WebServer.EXE /port:8080 /path:"D:\MyTests\BE_Test1\BlogEngine.Web_deploy\Debug_test1" /vpath:"/BE_Test1"

And I get...a Parse Error:



It looks like the page is barfing when it tries to load the PostCalendar user control.  Interestingly, the PostList user control loads fine.  I wonder why?

Looking at the default.aspx markup code, I see that the PostList user control is registered at the top of the page, but the Calendar user control is not.  What gives?



Well, it looks like, as Phil Haack once explained, the controls with the "blog" prefix are registered in the web.config.  Didn't know you could do that.  Pretty cool.

<pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true">
<controls>
<add namespace="Controls" tagPrefix="blog"/>
</controls>
</pages>


This doesn't fix my problem, though.  ASP.NET Parse Errors are usually an indication that the CLR can't find the referenced class in the assembly.  Well, I know the PostCalendar class is in my single assembly (.NET Reflector told me that), so maybe the CLR is not able to find the assembly itself.  Maybe I can help.  Let's modify the control registration in the web.config with the assembly attribute:

<pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true">
<controls>
<add namespace="Controls" tagPrefix="blog" assembly="BlogEngine.Web_deploy"/>
</controls>
</pages>


Hey, what do you know?  It worked!  Now, the page loads up just fine.  Note that this last change I made in the web.config in my build folder; if you try to change the original web.config and then run BE from the IDE, you'll get a compiler error.  It seems to me that these kinds of issues can introduce a lot of challenges to development, as you try to account for the fact that the web.config you deploy to a Production server will need to look slightly different than the web.config that you run in your IDE.  I wonder if there are any MSBuild tasks designed to modify the web.config spit out by the build engine?  Scott Guthrie has talked about other important changes that should occur in your web.config before deploying it to Production.  I wonder if anyone has written a MSBuild task to accommodate those changes?

Clicking around in my pre-compiled BE instance, everything seems to work fine; however, I did encounter one show-stopping error that prevents me from doing important administration tasks--like adding a new entry.  At least I know that issue's related to the BE distribution I downloaded, not my build experiment with aspnet_merge.

So, what have I learned?  Doing pre-compilation on complicated Web Site projects can be tricky business--particularly when using aspnet_merge.  I wonder if I should just demo how to migrate a Web Site project to a Web Application project?

 

 

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Brad on Friday, October 24, 2008 1:48 PM
Permalink | Comments (74) | Post RSSRSS comment feed

BlogEngine.NET Extensions

I've known for a while that BlogEngine.NET included a concept called "extensions" where you may bolt on various widgets, but as I read this account of a BlogEngine.NET experience (via DotNetKicks), I decided to take a look at the full list of extensions.  Wow.  I see that perhaps some of the work I did to customize my implementation may have already been solved via an extension.  Guess it pays to google before you build.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Technology Blog
Posted by Brad on Thursday, May 15, 2008 10:16 PM
Permalink | Comments (14) | Post RSSRSS comment feed

BlogEngine.NET

Well, after months of messing around looking at dasBlog, Subtext, DotNetNuke, and others, I finally landed on BlogEngine.NET v1.3.0.0 on which to build my website.  The thing is, though, I really don't want this site to be exclusively about blogging: if I did, I'd probably go really simple and do something with wordpress or blogger.  Ideally, I'd like some portion of my site to host some as-of-yet-unknown genealogy application and maybe dedicate other portions for other purposes (maybe a code garage sale).  The other thing is, I'm lazy and don't necessarily want to start a website from scratch--plus, I've been eager to explore some of these much-talked-about starter kits.  

Microsoft has a great list of starter kits, but none of them have blog engine components quite like those mentioned above.  Oh...one more thing...I'm pretty cheap and bought a pretty basic hosting package--i.e. no SQL server database package.  So, not wishing to persist my blog content to the mighty MS Access database, that seems to narrow my choices down to the XML file based BlogEngine.NET.  Not that that in any way diminishes the power of that platform.  I do like BlogEngine.NET for the most part.  I like how it leverages many aspects of the ASP.NET 2.0 framework including extending the membership provider model, http handlers and modules (for url rewriting), generics/predicates, and so forth.

Here's some modifications I made:
1. Added code to the XML membership provider to hash and salt passwords (I did add the fix for the recent security issue, too, not that it hurt me too badly since my passwords were already hashed)
2. Wrote a quote control so that I can display a favorite quote with every page request
3. Wrote a dynamic menu control so I can dynamically build my top menu from an XML file
4. Fixed a bug with the gravatar display
5. Added support for Silverlight 1.0

I think that's about all the changes I made to my current deployment of BlogEngine.NET, but my real goal was to create a site that could support multiple, distinct blogs.   There's been some discussion on how to make BlogEngine.NET appear to support multiple blogs--namely, by placing multiple instances of BlogEngine.NET in different sub-directories or subdomains.  I was hoping I could do the same by creating a few subdomains and hosting a new instance of the code in each, but my hosting provider doesn't appear to be able to support more than one ASP.NET 2.0 application per domain, so I begrudgling put up a single instance of the platform (what you're seeing now) and pretend I'm hosting multiple blogs by calling each category a blog.  Incidentally, is it common for a host provider to allow me to have only one ASP.NET application under my domain name?  It seems to me that if IIS 5.1 can support N number of ASP.NET applications under a single localhost site, surely my host provider could do the same.  

Anyway, a while back, I started drammatically extending BlogEngine.NET to support multiple blogs.  I got pretty far along, but I stopped when I started working on the controls.  If I'm looking at Blog X, I want all the controls in the sidebar to only show me content from Blog X: recent posts, comments, archive, authors, tags, categories--these should all be filtered to show just Blog X content.  It appeared to be a lot of work to remediate these controls, so I stopped--thinking it would be quicker to deploy multiple instances of BlogEngine.NET to my domain--only later to find out that my host provider wouldn't support such a thing.  So, in the near or far future, I'll probably resume my efforts to extend the platform for multiple blogs.  Either that or look into other people's work in this space.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Technology Blog
Posted by Brad on Wednesday, May 14, 2008 11:31 PM
Permalink | Comments (18) | Post RSSRSS comment feed