How to add a manifest resource?
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.

Post a new message to this list...

MuZZY
Hi,

I have a WinForms app source code with a batch file containing
compilation script:

csc /t:winexe /r:System.dll /r:System.Drawing.dll
/r:System.Windows.Forms.dll /r:Cassini.dll /win32icon:myicon.ico
/res:myicon.ico, MyCustomIcon /out:MyApp.exe MyForm.cs

which works fine if i compile from command line, but if i use VS.NET,
i get an exception in MyForm.cs on this line:

//-----------------------------------
Icon = new
Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyCustomIcon"));
//-----------------------------------

As i understand i need to add icon myicon.ico as a resource with the
resource name "MyCustomIcon".

How can i do that?

Thank you for any ideas!
Andrey
Reply to this message...
 
    
Sijin Joseph
Everything seems ok, why don't you use ILDASM.exe to check out under
what name myicon.ico has been added as a resource

it will look something like this in the disassembled output

..mresource <resource name>
{

}

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

MuZZY wrote:
[Original message clipped]

Reply to this message...
 
    
nzpcmad
You might have to add the .ico file to the project and (under the
Properties) set to "Embedded Resource"

Sijin Joseph <Click here to reveal e-mail address> wrote in message news:<#vg$$Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
    
MuZZY
nzpcmad wrote:
[Original message clipped]

That's what i've actually already done.
But i can't find a way to "name" this resource.
Of cource i can go without that, because by default the resource will be
given a name <namespace>.<filename> But i'd like to be able to customly
name it though.

Any ideas would be highly appreciated!

Thank you,
Andrey
Reply to this message...
 
    
nzpcmad
I use C# / Visual Studio 2003.

When I load the icon, I use:

this.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly).GetManifestResourceStream("Project
Name.Icon Name.ico"));

This works. I don't have sub-folders. If I did. I believe the path
would then be:

Project Name.Folder Name.Icon Name.ico"

Thanks

MuZZY <Click here to reveal e-mail address> wrote in message news:<8B61d.165870$9d6.49361@attbi_s54>...
[Original message clipped]

Reply to this message...
 
 
System.Drawing.Icon
System.Reflection.Assembly




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