.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification