How to add a manifest resource?

M

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
 
N

nzpcmad

You might have to add the .ico file to the project and (under the
Properties) set to "Embedded Resource"
 
M

MuZZY

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

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
 
N

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top