views:

151

answers:

1

Is there a recommended process for creating reusable ASP.NET assemblies that contain UserControls that can be shared across projects in separate solutions?

We have currently have a set of post-compilation steps that run aspnet_compiler.exe on the project, generate the precompiled assemblies using a given name, followed by aspnet_merge.exe to combine each individual control assembly into a single assembly - which is then copied into the bin directory for the project.

Unfortunately, user controls compiled in this manner don't 'play well' with the VS designer - and throw exceptions at design time that make working with pages that host them cumbersome.

Is there a better approach for doing this?

+1  A: 

That is the only approach that will put them into a portable stand-alone assembly like that. Sounds like you already know everything referenced here, but this is the best article I know of that discusses the technique:

http://blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx

What I've always done is just require the ascx to exist, too. The code-behind can be in the portable dll, but still require the ascx. You can help manage duplicates by keeping them all in one place and mapping virtual directories to that location. The advantage of this approach, even though it is low-tech, is that each app if it wants could customize the ascx's look. It could move things around or change the styling, etc, and the code-behind would be none-the-wiser as long as the changes didnt affect which server controls exist.

InfinitiesLoop