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 / December 2005

Tip: Looking for answers? Try searching our database.

Problems with Assembly.GetManifestResourceStream( type, string )

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rowland Shaw - 19 Dec 2005 11:59 GMT
I have an object "retval" of type "MyCompany.Department.MyCrystalRpt"
(from the watch window:)
retval.GetType().ToString()    "MyCompany.Department.MyCrystalRpt"    String

This report is compiled to be part of a class library, and even has it's
resources compiled in correctly:
(from the watch window:)
retval.GetType().Assembly.GetManifestResourceNames    {Length=2}    String()
(0)    "MyCompany.Department.MyCrystalRpt.resources"    String
(1)    "MyCompany.Department.MyCrystalRpt.rpt"    String

According to the documentation, "If the full name of type is
"MyNameSpace.MyClasses" and name is "Net", GetManifestResourceStream will
search for a resource named MyNameSpace.Net.", so I'd expect this:
(from the watch window:)
retval.GetType().Assembly.GetManifestResourceStream( retval.GetType(),
"MyCrystalRpt.rpt")
To return a System.IO.Stream; however it return Nothing/null.

Now, I realise that there are other ways to get the manifest resource stream
, for instance:
retval.GetType().Assembly.GetManifestResourceStream(
"MyCompany.Department.MycrystalReport.rpt") does return a System.IO.Stream;
howwever, this issue is code identified in a third party component vendors
code (thanks to a certain amount of IL debugging), and I don't believe the
fault is with them, but instead within the 1.1 Framework?
Or am I being really stupid and mis-interpreting the documentation?
Rowland Shaw - 19 Dec 2005 13:05 GMT
Further down the rabbit hole I go...

It turns out that by some oddity, my classes had a different namespace than
the resources (by case only)

> I have an object "retval" of type "MyCompany.Department.MyCrystalRpt"
> (from the watch window:)
[quoted text clipped - 23 lines]
> fault is with them, but instead within the 1.1 Framework?
> Or am I being really stupid and mis-interpreting the documentation?
"Jeffrey Tan[MSFT]" - 20 Dec 2005 01:36 GMT
Hi Rowland,

It seems that your problem is caused by using a wrong namespace, which
caused the null reference returned. Yes?

Ok, after fixing this issue, Assembly.GetManifestResourceStream works well
for you now, yes? If you still have any concern, please feel free to tell
me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


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.