Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Load resource into assembly
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01007930
Message ID:
01007931
Views:
10
Duuhh I have to add the namespace in front of the filename. Something like this:
Stream stream = GetType().Assembly.GetManifestResourceStream("myNameSpace.Level.bin");
I also have to make sure that the namespce in the able line matches the DefaultNameSpace.

Einar

>I am trying to run some sample code but I am having some trouble loading a resource file (Level.bin) into the assembly so that I can extract data from the file at runtime using the code:
>
>Stream stream = GetType().Assembly.GetManifestResourceStream("Level.bin");
>Byte[] data = new Byte[stream.Length];
>stream.Read(data, 0, (int) stream.Length);
>
>An exception is caught on the 2nd line stating that object reference is not set to an instance of an object. The GetManifestResourceStream() method is not throwing an exception but it appears that there is never an object stream created.
>I have added the file Level.bin to the project and set the build action to Embedded Resource.
>Is there anything that I am missing?
>
>Thanks,
>Einar
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform