Server Control Toolbox Icons without VStudio.net
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngescalate' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Andy Smith (VIP)
I've asked this server times on a multitude of lists, and never gotten
an answer.

How do I give my server controls a toolbox icon without using visual
studio.net?

I'm aware that with visual studio, you just add an icon into the
project with the same name as the control, and set some compile option
on it.

however, I need to do it from the command line or with Nant.
Can ANYBODY give me a clue on how to do this?

__
Andy Smith
Chief Code Monkey

Reply to this message...
 
    
Saurabh Nandu (VIP)
I did find a way doing it manually, but I don't know if it's the correct
way to do it ... but it works !

1) Create your UserControl / Component (e.g MyUserControl class) and
markup the class with
[ToolboxBitmap(typeof(Bitmap))] attribute
2) Compile this class into a module (Yeha a module, could not get the
assembly to work!!)
csc /t:module MyUserControl.cs
This will create a file called MyUserControl.netmodule
3) Create a bitmap 16x16x16, with the fully qualified name of the class
that has the attribute. i.e. namespace.classname.bmp
In my case since the class does not live in a namespace I use
MyUserControl.bmp
4) Use the al.exe (Assembly Linker) tool to embed the resource.
Al MyUserControl.netmodule /t:library /embed:MyUserControl.bmp
/out:MyUserControl.dll
This step will create an assembly linking the MyUserControl.netmodule
and the embed resource file!
5) Add this control to your toolbox !

Hope this helps !

Regards,
Saurabh Nandu
www.MasterCSharp.com
Master C#, the easy way...

[Original message clipped]

Reply to this message...
 
    
G. Andrew Duthie (VIP)
I've managed to make this work, but the trick is that the bitmap must
have the same name as the class, including the namespace name (or
names). So if the fully qualified name of your class is Foo.Bar, your
bitmap should be named Foo.Bar.bmp. It should also be a 16x16 bitmap (I
don't know if there are any color restrictions). Once you've got the
file named correctly, you should be able to compile it as an embedded
resource (add the /resource command-line option), and you should be good
to go.

hth,

--
G. Andrew Duthie
Graymad Enterprises, Inc.
http://www.graymad.com
Click here to reveal e-mail address
Author, ASP.NET Step By Step
http://www.amazon.com/exec/obidos/ASIN/0735612870/
=20

[Original message clipped]

Reply to this message...
 
    
Saurabh Nandu (VIP)
Just an Update Andy,

Actually you can compile your user control as
csc /resource:MyUserControl.bmp /t:library MyUserControl.cs
And the Bitmap file will be correctly embedded !!

I missed this earlier since I followed the .NET Documentation for the
csc compiler 'resource' switch and it *wrongly* states 'The .NET
Framework resource file you want to embed in the output file.', while it
can actually even embed normal bitmaps!

Thanks to G. Andrew Duthie suggestion !!

Regards,
Saurabh Nandu
www.MasterCSharp.com
Master C#, the easy way...

[Original message clipped]

Reply to this message...
 
 
System.Web.UI.UserControl
System.Windows.Forms.UserControl




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com