J
J.Marsch
Hello all:
I am trying to build a resource dll that will house icons, and I'm afraid
that I'm not having much luck reading it. Can you lend hand (or just point
me to a good primer).
Here's what I've done so far: (VS.NET 2003/C#)
1. Created an empty project for the resource dll. Output type is class
library.
2. Added a bunch of icon files to the project (add existing item).
3. Set the build action of each icon file to "embedded resource".
4. So, this project is of type class library, has no references, and only
contains .ico files, no .cs files.
Next, in a separate test exe, I run the code below to try to simulate
reading the resources. I get an ArgumentException in the constructor of the
ResourceReader: "Stream is not a valid resource file". (the code is below)
I think that either I am not building the resource dll correctly, or I am
not using the right resource class to try to read it. Any hints?
private void ReadResources(string resourceFileName) // resourceFileName ==
"myResources.dll"
{
System.Resources.ResourceReader reader = new
System.Resources.ResourceReader(resourceFileName);
try
{
System.Collections.IDictionaryEnumerator enumerator =
reader.GetEnumerator();
while(enumerator.MoveNext())
System.Diagnostics.Debug.WriteLine(enumerator.Key);
}
finally
{
reader.Close();
}
}
I am trying to build a resource dll that will house icons, and I'm afraid
that I'm not having much luck reading it. Can you lend hand (or just point
me to a good primer).
Here's what I've done so far: (VS.NET 2003/C#)
1. Created an empty project for the resource dll. Output type is class
library.
2. Added a bunch of icon files to the project (add existing item).
3. Set the build action of each icon file to "embedded resource".
4. So, this project is of type class library, has no references, and only
contains .ico files, no .cs files.
Next, in a separate test exe, I run the code below to try to simulate
reading the resources. I get an ArgumentException in the constructor of the
ResourceReader: "Stream is not a valid resource file". (the code is below)
I think that either I am not building the resource dll correctly, or I am
not using the right resource class to try to read it. Any hints?
private void ReadResources(string resourceFileName) // resourceFileName ==
"myResources.dll"
{
System.Resources.ResourceReader reader = new
System.Resources.ResourceReader(resourceFileName);
try
{
System.Collections.IDictionaryEnumerator enumerator =
reader.GetEnumerator();
while(enumerator.MoveNext())
System.Diagnostics.Debug.WriteLine(enumerator.Key);
}
finally
{
reader.Close();
}
}