We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

TreeView Virtual Grid

Hi,

Bitmap bm = new Bitmap(GetType().Module.Assembly.GetManifestResourceStream("CustomGridCell.minus.bmp"));

This line produces the following error.

Value of 'null' is not valid for 'stream'.

What would cause this error? Do i need to add some kind of assembly to my project?

I have the bmp files in the project.

4 Replies

AD Administrator Syncfusion Team February 8, 2007 11:45 PM UTC

Hi Adnan,

What would cause this error?
>>>>>>>
The reason for getting this issue is that you are not setting the "minus.bmp" file build action as Embeded Resource. By default, it should be content. Please try the following steps to resolve this.

1) Open your application
2) Right click on the "minus.bmp" file in the solution explorer and go the properties.
3) set the Build Action to Embeded Resource in properties.
4) Run your application.

Please let me know if this helps.

Best regards,
Haneef


AS Adnan Sohail February 9, 2007 03:49 PM UTC

This didnt solve the problem.

I have a folder called "Product" and i have the form that contains a virutal grid in Product's folder. Bmps are also in that folder.

Again this line is producing error.
Bitmap bm = new Bitmap(GetType().Module.Assembly.GetManifestResourceStream("CustomGridCell.minus.bmp"));

Just to let you know this is a separate project and not the sample project.


AD Administrator Syncfusion Team February 9, 2007 08:16 PM UTC

Hi Adnan,

Reading the information from the resource to a stream is performed with a method call to GetManifestResourceStream. The parameter that is passed to this method is the name of the resource that is to be accessed. The resources are named using the following convention: .. So if you embed a file named minus.bmp into your project in the MyNS namespace, you have a resource in the manifest named MyNS.minus.bmp.If you want to get resource streams, use the following code:

Bitmap bm = new Bitmap(GetType().Module.Assembly.GetManifestResourceStream("MyNS.minus.bmp"));

The only tricky thing here is you need to prepend the name of your Assembly to the name of the resource stream. If you want to view all the resource streams available to you, use the following code:

Assembly a = Assembly.GetExecutingAssembly();
string resNames[] = a.GetManifestResourceNames();

foreach(string s in resNames)
{
Console.WriteLine(s);
}

Best regards,
Haneef


AS Adnan Sohail February 9, 2007 08:25 PM UTC

Thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon