elucid8 elucid8 - 1 month ago 10x
C# Question

Strongly Typed Access to Embedded Resources

I'm trying to establish access to an embedded SQL resource file I've created in a Class Library. However, I'm not sure where to go from here.

I've accessed the resource using:


My understanding is that there is a way to access them in a strongly typed fashion, but I can't seem to get a handle on the project or the solution to browse through their respective properties or resources programatically.

What am I missing?


Although I did get some great suggestions (see Philip Daniels' answer - good stuff), none of them really addressed my specific concerns. However, I found that the easiest way to accomplish this was to do the following:

  1. Right click your project and select 'Properties'
  2. Select the 'Resources' tab. Create a new resources file if necessary.
  3. In the upper left hand corner there is a drop down that defaults to 'Strings'. Click this box and choose 'Files'.
  4. Drag and drop the resource file you'd like to embed in the project.

You can now access a strongly typed resource using the following syntax:


In my situation, this worked perfectly as I am storing inline SQL in these files and it returns the sql embedded in the file. Keep in mind, however, that by defaults these resources are linked and not embedded, but you can change their property to set them to embedded.

Hope this helps someone!