473,503 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reusable UserControl Library in ASP.NET 2.0 RC1

In a blog from Scott Guthrie
(http://weblogs.asp.net/scottgu/archi...28/423888.aspx) I found a
sample to build a UserControl Library inside one ASP.NET project and then
deploy it to other projects and reuse it.
He suggests that you "publish" the web site to a directory and include this
directory into your (second) web site. I tried this but VS (and the
aspnet_compiler) complains that my user control now is implemented twice.
When I remove the "aspx" files and only copy the compiled dlls I cannot
access the user controls for they are not found.
Unfortunately, Scotts sample doesnt go into details about how to include
these UserContorls into new web sites.
So the question is:
If I have the compiled user control (e.g.
"App_Web_MyUserControl.ascx.12345678.dll") copied into the new web site, how
can I reference the control therein in my page ?

Guenter from Frankfurt/Germany
Nov 19 '05 #1
5 3237
One technique I've been exloring is using MSBuild and ILMerge to
produce a truely reusable assembly of user controls:

http://odetocode.com/Blogs/scott/arc...0/06/2326.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 19 Oct 2005 04:35:02 -0700, "Guenter"
<gtschech(at)hotmail(dot)com> wrote:
In a blog from Scott Guthrie
(http://weblogs.asp.net/scottgu/archi...28/423888.aspx) I found a
sample to build a UserControl Library inside one ASP.NET project and then
deploy it to other projects and reuse it.
He suggests that you "publish" the web site to a directory and include this
directory into your (second) web site. I tried this but VS (and the
aspnet_compiler) complains that my user control now is implemented twice.
When I remove the "aspx" files and only copy the compiled dlls I cannot
access the user controls for they are not found.
Unfortunately, Scotts sample doesnt go into details about how to include
these UserContorls into new web sites.
So the question is:
If I have the compiled user control (e.g.
"App_Web_MyUserControl.ascx.12345678.dll") copied into the new web site, how
can I reference the control therein in my page ?

Guenter from Frankfurt/Germany


Nov 19 '05 #2
Hi Scott,

the article read great, but I coudn't manage to get it to work yet.
(I am running on RC1, BUild 50727)

Problems are many:
* first, I had to recognize that ILMerge is not an intrinsic part of the
..net framework (ok, one who can identify and follow links in your post
clearly has an advantage :-)
* then, the TempDirectory variable is not declared by default, I had to
insert a <PropertyGroup>
* and now the persisting problem: my Temp Directory contains spaces, and I
can't get MSBuild to surround the dll names with quotes (seems that the
<CreateItem does not offer this feature)

Is there a way around that ?

Guenter

"Scott Allen" wrote:
One technique I've been exloring is using MSBuild and ILMerge to
produce a truely reusable assembly of user controls:

http://odetocode.com/Blogs/scott/arc...0/06/2326.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 19 Oct 2005 04:35:02 -0700, "Guenter"
<gtschech(at)hotmail(dot)com> wrote:
In a blog from Scott Guthrie
(http://weblogs.asp.net/scottgu/archi...28/423888.aspx) I found a
sample to build a UserControl Library inside one ASP.NET project and then
deploy it to other projects and reuse it.
He suggests that you "publish" the web site to a directory and include this
directory into your (second) web site. I tried this but VS (and the
aspnet_compiler) complains that my user control now is implemented twice.
When I remove the "aspx" files and only copy the compiled dlls I cannot
access the user controls for they are not found.
Unfortunately, Scotts sample doesnt go into details about how to include
these UserContorls into new web sites.
So the question is:
If I have the compiled user control (e.g.
"App_Web_MyUserControl.ascx.12345678.dll") copied into the new web site, how
can I reference the control therein in my page ?

Guenter from Frankfurt/Germany


Nov 19 '05 #3
Hmm - my temp directory and project directory avoid spaces in the
names. I'd have to experiement with MSBuild a little more.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 20 Oct 2005 01:47:04 -0700, "Guenter"
<gtschech(at)hotmail(dot)com> wrote:
Hi Scott,

the article read great, but I coudn't manage to get it to work yet.
(I am running on RC1, BUild 50727)

Problems are many:
* first, I had to recognize that ILMerge is not an intrinsic part of the
.net framework (ok, one who can identify and follow links in your post
clearly has an advantage :-)
* then, the TempDirectory variable is not declared by default, I had to
insert a <PropertyGroup>
* and now the persisting problem: my Temp Directory contains spaces, and I
can't get MSBuild to surround the dll names with quotes (seems that the
<CreateItem does not offer this feature)

Is there a way around that ?


Nov 19 '05 #4
Hi Scott,

after playing around with MSBuild for awhile, I have modified your build
configuration and have achieved the following:
* the build process can cope with blanks (at least inside the "temp" path)
* the build process only rebuilds the target if files are changed
* a "clean" cleans the temp directory
There's just one or thing missing (maybe you've got an ieas for that):
I explicitly have to reference the DLL file inside the webb app; just
erferencing the project does not do. There must be some information inside
the project file that tells VisualStudio which files are to be copied as part
of the build processs, but I can't figure out where that information lives.

For your records, this is how my build file looks now:

<PropertyGroup>
<ILMergeEXE>"$(ProgramFiles)\Microsoft\ILMerge\ILM erge.exe"</ILMergeEXE>
<TempDirectory>$(Temp)\MSBuildTemp</TempDirectory>
</PropertyGroup>
<Target Name="PrecompiledAssemblies" Inputs="@(Compile)"
Outputs="$(TempDirectory)\PrecompiledApp.config">
<AspNetCompiler Debug="false" PhysicalPath="$(MSBuildProjectDirectory)"
TargetPath="$(TempDirectory)" Updateable="false" Force="true"
VirtualPath="$(MSBuildProjectName)" />
</Target>
<Target Name="SingleDll" DependsOnTargets="PrecompiledAssemblies"
Outputs="$(OutputPath)\$(MSBuildProjectName).dll"
Inputs="$(TempDirectory)\PrecompiledApp.config">
<CreateItem Include="$(TempDirectory)\bin\*.dll">
<Output ItemName="PrecompiledAssemblies" TaskParameter="Include" />
</CreateItem>
<Exec Command="$(ILMergeEXE)
/out:$(OutputPath)\$(MSBuildProjectName).dll /targetplatform:v2
%22@(PrecompiledAssemblies, '%22 %22')%22" />
</Target>
<Target Name="AfterClean">
<RemoveDir Directories="$(TempDirectory)" />
</Target>
(I hobe this survives the post...)

Feel free to use it, maybe even to update your blog entry (I would feel
proud about that :-)

Guenter

"Scott Allen" wrote:
Hmm - my temp directory and project directory avoid spaces in the
names. I'd have to experiement with MSBuild a little more.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 20 Oct 2005 01:47:04 -0700, "Guenter"
<gtschech(at)hotmail(dot)com> wrote:
Hi Scott,

the article read great, but I coudn't manage to get it to work yet.
(I am running on RC1, BUild 50727)

Problems are many:
* first, I had to recognize that ILMerge is not an intrinsic part of the
.net framework (ok, one who can identify and follow links in your post
clearly has an advantage :-)
* then, the TempDirectory variable is not declared by default, I had to
insert a <PropertyGroup>
* and now the persisting problem: my Temp Directory contains spaces, and I
can't get MSBuild to surround the dll names with quotes (seems that the
<CreateItem does not offer this feature)

Is there a way around that ?


Nov 19 '05 #5
On Thu, 20 Oct 2005 07:40:23 -0700, "Guenter"
<gtschech(at)hotmail(dot)com> wrote:

There's just one or thing missing (maybe you've got an ieas for that):
I explicitly have to reference the DLL file inside the webb app; just
erferencing the project does not do. There must be some information inside
the project file that tells VisualStudio which files are to be copied as part
of the build processs, but I can't figure out where that information lives.

That's another area that I could not tidy up to the point I would like
it. I've been hesitant to spend anymore time with it at this date
because I know the ASP.NET team is releasing a merge and deplyoment
tool around RTM, so I want to wait and see what that tool looks like.

Feel free to use it, maybe even to update your blog entry (I would feel
proud about that :-)


Sure thing :) I'm going to add a reference to this post in the
comments for people to find.

--
Scott
http://www.OdeToCode.com/blogs/scott/

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1528
by: Tony Marston | last post by:
For those of you who think that using XSL/XML to create your HTML output from a PHP application is not a viable proposition as XSL is a clunky language, it is too verbose and it cannot get the job...
27
2234
by: Matt Kruse | last post by:
Since this topic has come up several times in other threads, I thought I'd make a separate thread and gather opinions from (hopefully) a more varied range of newsgroup participants. What are...
9
3332
by: Richard Brown | last post by:
Can anyone give me a good argument one way or another? I have an 'address' set of fields that are used in various situations (a client has an address, a destination has an address, etc). These...
3
12265
by: Armen Rizal | last post by:
Hello all, Is there anybody know where I can find reusable pl/pgsql samples or function library ? Thanks, Armen
2
3371
by: gerry | last post by:
based on MSPress's ASP.NET 2.0 Applications Advaced Topics ( Table 12-3 p.472 ), and most events should be automatically wired up when @Control AutoEventWireup="true". ie. Page_InitComplete() {}...
2
2810
by: Mark Collard | last post by:
The ToolBar control allows you to add toolbar buttons. When you add a button, the button is not only displayed in the toolbar, but also added as a separator control in the form/usercontrol your...
5
1443
by: billsahiker | last post by:
I saw one post here that basically said no way, but not sure which vs version was being discussed. Using vs 2005 I develped a user control in a vb project and would like to use that usercontrol in...
13
2396
by: Screaming Eagles 101 | last post by:
Hi, I have a solution containing two projects - main project with main form containing a statusstrip - second project containing a usercontrol. I have added the usercontrol to my main form,...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.