Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a project ModuleManager in which I have added an icon file into the Resource folder. This will be compiled into an dll. Later If I want to fetch the Icon,I know I have to use

C#
System.Drawing.Icon icon1 = Assembly.GetExecutingAssembly().GetManifestResourceStream


But I am not able to find the correct syntax.Any help will be appreciated.

What I have tried:

I have tried the following line-
C#
System.Drawing.Icon icon1 = Assembly.GetExecutingAssembly().GetManifestResourceStream(ModuleManager.resources.iconfilename)

Which is returning null.
Posted
Updated 1-Jun-16 7:34am
v2

1 solution

Try
C#
string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();

It will give you a list of all the existing resources and their full names.
This is to make sure the icon is there.

Then do
C#
System.Drawing.Icon icon1 = new System.Drawing.Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(ModuleManager.resources.iconfilename));

if ModuleManager.resources.iconfilename contains the correct name.
 
Share this answer
 
v3
Comments
DSomesh 1-Jun-16 13:49pm    
This returns me only one string containing " ModuleManager.Properties.Resources.resources"
DSomesh 1-Jun-16 13:58pm    
Got it!!I missed the part of marking the resource as embedded resources.
George Jonsson 1-Jun-16 14:06pm    
Good. Debugging helps. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900