How does GoImage decide to load an image?

I’m trying to develop a GoDiagram app using Eiffel Envision, modelling it after the C# ProtoApp sample.

It appears to me that the sample app loads the image from the default
ProtoApp.Images ResourceManager, but in my application, I get this

LoadImage: System.IO.FileNotFoundException: beany.bmp
at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
at System.Drawing.Image.FromFile(String filename)
at Northwoods.Go.GoImage.LoadImage()

As far as I can tell, the default resource manager is being correctly
set up in my application. Is there something in particular I need to do
to get the images from the resources instead of from the file?


Greg C

If GoImage.LoadImage can’t find a resource in a ResourceManager, it tries to load a file from disk. Thus in your case it must be failing to find “beany.bmp” in the ResourceManager. Are you sure you have a valid ResourceManager and that it really has an image named “beany.bmp”?

I’ve run into a very similar problem… i’m using . I’m trying to load an image from the webserver (in this case, localhost) and get the same error. I’ve set up a resource manager and i can get an image to load from my local machine specifying a path for the file, ie, “c:<FONT size=2>my documents\icons\WWW.ico”, however, when i use “…/images/file_name.gif” as the file, I run into the error. My code is as follows:
Dim rm As Resources.ResourceManager
tNode.Initialize(rm, “…/images/file_name.gif”, “”)
i’ve also tried “images/file_name.gif” but to no avail… maybe my eyes are failing me and i’m missing something really simple…
Any ideas? suggestions?

If you are using ASP.NET, you should be using Page.MapPath to find the real/physical directory path. For example:
MapPath(this.TemplateSourceDirectory) + “/images/file_name.gif”

can you please tell me how I can write this code in window application of

I am using tree app application in which imageid is inserting in database.
but when we want to fetch that id from database and want to so image as per imageid.
but not finding where to write code for this.
can you please tell me.
If you are saying that the database contains some identifier used to select an image from a ResourceManager or ImageList, then you should just initialize the GoImage in the normal manner. This typically means setting the GoImage.DefaultResourceManager or GoImage.DefaultImageList static/shared property, and then setting GoImage.Name or GoImage.Index property on the individual GoImage.
If you are saying that the database contains Image data, then you need to construct the System.Drawing.Image yourself and assign the GoImage.Image property instead of assigning the ResourceManager/Name or ImageList/Index pairs of properties.
You could have it do this automatically, and only on demand, by overriding GoImage.LoadImage.