Hi,
I've got an application that uses Assembly.LoadFrom and
Activator.CreateInstance to dynamicly load assemblies and create objects.
Tese assemblies containes classes which exposes a property, ItemImage.
ItemImage returns an Image object.
The image (icon) it should represent is embedded in the assembly as a
resource and browsable through reflecor.
When trying to retrieve the image through the standard resource reading
code:
<code>
Type thisType = this.GetType();
Assembly thisAssembly = Assembly.GetExecutingAssembly();
string iconName = thisType.ToString() + ".ico";
Stream imageStream = thisAssembly.GetManifestResourceStream(iconName);
Bitmap image = new Bitmap(imageStream);
return (Image)image;
</code>
the stream returned is always null. I've tried to hardcode the resource name
as displayed in reflector, no luck. I've also tried using GetEntryAssembly
and GetAssembly(thisType), still no luck.
What am I doing wrong?

Signature
Patrik L?wendahl
www.cshrp.net - "Elegant code by witty programmers"
Mattias Sj?gren - 21 May 2004 19:46 GMT
Hej Patrik,
Does the code work correctly when the library is loaded the normal
way, not using Assembly.LoadFrom()?
Does thisAssembly.GetManifestResourceNames() return anything useful?
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Roger Tan [MSFT] - 14 Jun 2004 22:00 GMT
Patrik, how are you embedding the icon? Are you talking about using the
/win32icon switch with csc.exe or al.exe? If so, I don't believe (from what
I know) the icon used is included when you reflect on the assembly. I
looked in ILDASM and couldn't see any trace of the icon file I used to
embed into an assembly.