Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / June 2004

Tip: Looking for answers? Try searching our database.

Load Resources from Dynamicly loaded assemblies

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrik L?wendahl - 21 May 2004 15:52 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.