Iver's web place

Life is a journey ... taken one shot at a time!

How to create custom controls in ASP.NET part 3 of 3

Deploying Custom Controls

If you're using the Visual Studio IDE, maybe you don't know the building way from the command line. I have two files (FoxyGridView.cs and FoxyGridView.Methods.cs) and I need to generate the build from the command line. So the sintax is the next:
C:\Program Files\Microsoft Visual Studio 9.0\VC> csc /t:library /out:FoxyGridView.dll /r:System.dll /r:System.Data /r:System.Drawing /r:System.Web FoxyGridView.cs FoxyGridView.Methods.cs

Also we can set the control assembly properties, a strong assembly name consists of four parts: assembly name, version, culture, and public token key. Only we need to create a file named AssemblyInfo.css (or maybe other name), with the following code to the file:
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyKeyFile("KeyFile.snk")]
 

By default the Visual Studio 2008 add a file with the common attributes and the respectives comments about. Wheter you wish to sing the assembly. You can use the following command:
C:\Program Files\Microsoft Visual Studio 9.0\VC> sn -k KeyFile.snk

Don't forget to put the code and AssemblyInfo.cs file and key file into the same folder and use the following command to compile and sign the FoxyGridView.cs file to strongly named assembly, which will be named FoxyGridView.dll in this case:
C:\Program Files\Microsoft Visual Studio 9.0\VC> csc /t:library /out:FoxyGridView.dll /r:System.dll /r:System.Data /r:System.Drawing /r:System.Web FoxyGridView.cs FoxyGridView.Methods.cs AssemblyInfo.cs

To install a control to the GAC, you need to run the .NET command prompt (Start -> Programs -> Microsoft VS.NET -> VS.NET Tools -> VS.NET prompt) and start the gacutil.exe tool with -i parameter (install) and the full path to the control's dll.
gacutil.exe -i c:\Projects\FoxyGridView.dll

Adding Custom Control to the Visual Studio Toolbox

For adding your custom control to the toolbox Right-click the Toolbox area and select "Choose Items" from the pop-up menu to launch the "Choose Tool Items" dialog box.

toolbar image

After that use the "Browse" button to navigate to the directory where the assembly is located and select it.

browse image

And now, we can use the custom control from our Visual Studio Toolbox.
Resources
Professional ASP.NET 2.0 Server Control and Component Development
Dr. Shahram Khosravi
ISBN-13: 978-0-471-79350-2
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471793507.html
http://support.microsoft.com/kb/315682
Trackback URI: http://en.iver.com.mx/index.php?trackback/3

#1 Re: How to create custom controls in ASP.NET part 3 of 3

Dark Lord, <> / 24 January 2009  
avatar

que onda con tu vida we, no que estabas casadisimo con linux y con java y ahroa me sales conque pones tutoriales de .net, ya estas com oel peje, congruencia joven congruencia joven :D
chido tu site wey que estes bien

[ Reply (0) ]

#2 Re: How to create custom controls in ASP.NET part 3 of 3

HomeTube, <sunnyangel31(at)gmaildotcom> / 23 July 2010  
avatar

I often use Visual Studio IDE and your article was helpful a lot! Thanks

[ Reply (0) ]

#3 Re: How to create custom controls in ASP.NET part 3 of 3

Iván Jaimes, <ivandotiver(at)gmaildotcom> / 23 July 2010  
avatar

Your welcome my friend! Cheers, BTW nice video.

[ Reply (0) ]

Leave a Comment

Write the captcha code you are seeing.

Comment XML feeds: RSS | Atom

Blog Calendar

July 2010
Sun Mon Tue Wed Thu Fri Sat
27 28 29 30 1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
1 2 3 4 5 6 7