Embeded resources in Class Libraries

  • Thread starter Thread starter Brian Reed
  • Start date Start date
B

Brian Reed

How do I get icons/bitmaps/cursors embedded in a resource file in my C# .NET
class library? In my project I added an icon resource through 'Add New
Item', 'Resource Type', 'Icon'. I changed the Build Action to 'Embedded
Resource' and rebuilt my project.

In my project, I tried to load the icon with the following code:

icon = new icon(GetType(), "MyDefaultNamespace.MyIcon.ico")

and I get an exception saying it does not know about MyIcon in the class
CTestClass.

What might I be doing wrong? Are there any tools I can use to look at the
compiled DLL and look into its embedded resources?

Thanks,
 
You can use file->open->file in vs.net IDE to view a
file's embedded resources.
-----Original Message-----
How do I get icons/bitmaps/cursors embedded in a resource file in my C# .NET
class library? In my project I added an icon resource through 'Add New
Item', 'Resource Type', 'Icon'. I changed the Build Action to 'Embedded
Resource' and rebuilt my project.

In my project, I tried to load the icon with the following code:

icon = new icon(GetType
(), "MyDefaultNamespace.MyIcon.ico")
 
Hello Brian,

You may embed bitmaps to assembly via resource files. There is a Microsoft
Knowledge Base article describing this topic in detailed with a completed
sample code. This step-by-step article describes how to use Visual C# .NET
to embed resources as part of the assembly, and then access the resources
at run time. You may get it from the link below:

HOW TO: Embed and Access Resources by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q319292&#5

In addition, you may use the reseditor.exe utility to edit a resource file.
It provides a graphical interface that allows you to construct .resources
and .resx files containing bitmaps, icons, and strings. Please note that
this tool is a SDK sample in the
"FrameworkSDK\Samples\Tutorials\resourcesandlocalization\reseditor" folder
by default, you are required to compile it before using it.

I hope this information is helpful for you.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer
Get Secure! ¨C www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.
--------------------
| From: "Brian Reed" <[email protected]>
| Subject: Embeded resources in Class Libraries
| Date: Fri, 19 Sep 2003 14:34:02 -0700
| Lines: 19
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: 66.166.27.66
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52786
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| How do I get icons/bitmaps/cursors embedded in a resource file in my C#
NET
| class library? In my project I added an icon resource through 'Add New
| Item', 'Resource Type', 'Icon'. I changed the Build Action to 'Embedded
| Resource' and rebuilt my project.
|
| In my project, I tried to load the icon with the following code:
|
| icon = new icon(GetType(), "MyDefaultNamespace.MyIcon.ico")
|
| and I get an exception saying it does not know about MyIcon in the class
| CTestClass.
|
| What might I be doing wrong? Are there any tools I can use to look at the
| compiled DLL and look into its embedded resources?
|
| Thanks,
|
|
|
|
 
Back
Top