Creating a User Control Library

  • Thread starter Rex the Strange
  • Start date

R

Rex the Strange

Hi all,

In playing around with the techniques in this article:

http://msdn.microsoft.com/en-us/library/aa479318.aspx#customcontrolfromusercontrol_topic7

as well as other sources, I've found the following: there are two ways
to create a compiled user control / user control library:

1 - use the techniques mentioned in the aforementioned article
2 - create a "web application" with your user controls

Each technique, however, has its pitfalls. If you use technique #1
then the resulting dll file that is created is given a funky name
(usually web_app_[your control name][hash code] which is messy and
difficult to interpret and probably not much use if you make a bunch
of these.

Technique #2 does away with this hashed name issue by creating a dll
with the name of the project (which would be desirable) and it has the
added bonus that you can add it as a project reference (assuming the
project is in your current solution) but doesn't quite do what is
wanted either, because you can't embed the xhtml code into the dll
(which you can to with a web site - by unchecking "allow this
precompiled site to be updatable."

Possible solutions:

For #1 - rename the dll to the desired name. However, if you simply
change the file name then the compiler barfs whenever you try to use
it. This is the error I got:

Error 2 Could not load file or assembly 'testcontrol' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)

So, clearly, there is something inside the dll which specifies the
file name.

Question #1 - Is there a way to change the name of one of these dll
files?

For #2 - Compile the application so that the xhtml is embedded into
the dll. However, after searching the options in Visual Studio
extensively I can see no such option and googling the issue seems to
indicate that this is not possible.

Question #2 - Is this possible?

A positive answer to either question would help immensely (and a
negative to both would probably result in a wish list request to
Microsoft).

Thanks,

rts.
 
Ad

Advertisements

P

Patrice

Any reason for using a UserControl ? Generally you would go rather with a
CustomControl if your overgoal is to distribute this control.

As a control is a class you could use a class library project and use the
render method to render the appropriate markup but then you won't have an
ascx file (coming back to customcontrol) and likely a suboptimal
designexperience (you could just add this control inside a placeholder).

Some clarification about your overgoal might help (if you want to provide a
control with no ascx, have you checked custom controls ?).
 
P

Patrice

"overall goal" not "overgoal". Not a native english speaker. At least I'm
consistent...
 
Ad

Advertisements

R

Rex the Strange


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top