How can i include a resource in a .NET PE (Portable Executable) in Visual Studio 2010?
In the olden days we would create a resource script file:
wumpa.rc:
jqueryjs RCDATA "jquery.js"
SplashLogo PNG "Hello world.png"
ReportLogo RCDATA "ReportLogo.png"
Users ICON "User XP.ico"
Toolbar BITMAP "StandardToolbar24_32bpp.bmp"
Add that file to the project, and the compiler would compile the .rc
file; including resources in the final executable image.
What is the managed/.NET/Visual Studio mechanism to include resources?
See also
- MSDN: Resource Files (Visual Studio)
- MSDN: res Protocol
- MSDN: Using Resources in MCML
- SO: What is res://*/ in .net?
- creating HTML content using resx:// protocol and embedded resources
- How to build a managed assembly that contains Win32 resources using Visual Studio 2005
These have to be standard resources; you know the kind that everyone can read as resources:
- Resource Hacker would show as resources
- PEView would show as resources
- Internet Explorer can read using the
res
protocol (e.g.res://c:\foo\MyProgram.exe/PNG/SplashLogo
)
Things i've tried that don't work:
Adding resources to the
Resources.resx
file:Adding resources to the
Resources.resx
file, and specifying a build action of Resource:(also tried Build actions: Embedded Resource, as was suggested to me in 2008)
Update: What didn't work
i tried adding a file (wumpa.rc
) to the project:
wumpa.rc:
SplashPNG PNG "Splash.png"
By default it didn't work. i tried changing the Build Action of wumpa.rc
:
- Content (the default): didn't work
- Compile: "A namespace cannot directly contain members such as fields or methods"
- Embedded Resource: didn't work
- Resource: didn't work
What i get (nothing):
What i expect (something):
And then when you point Internet Explorer at the resource (using its res
protocol):
res://C:\Develop\Avatar\LocaleInfo\LocaleInfo.exe\PNG\SplashPNG
IE can find it:
.rc
file to my solution and have Visual Studio's resource compiler compile it? – Ian BoydWebBrowser
control, or its nativeIWebBrowser
COM object). But i have no interest in adding ares
file, as that requires a compiler. i'm used a development tool where you add a.rc
file to the solution as easily as you add a.cs
file - and the compiler/linker processes it - doing its job. – Ian Boyd