You have to ensure that you use the fully qualified name for the resource.
This will depend on your solution structure.
The resource name is probably something like "MyApplication.MyImage.bmp"
If you can't devine the resource name add a bit of temporary code to the
constructor...
public MyClass
{
InitializeComponent();
//tempororary code
string[] names=this.GetType().Assembly.GetManifestResourceN ames();
foreach(string s in names)
System.diagnostics.Trace.WriteLine(s);
//temporary code
}
This will dump all the names to the output pane and you can see how they're
named. Once you know, delete the temporary code.
--
Bob Powell [MVP]
C#, System.Drawing
The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
Read my Blog at
http://bobpowelldotnet.blogspot.com
"Shailaja Kulkarni" <cr*********@hotpop.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
Hi Bob,
thanks for your input, I tried this way but still I could not get the
desired result.
While I am trying to compile the project getting this exception message
" An exception occurred while trying to create an instance of
ShapeLibrary.BaseShape. The exception was "'null' is not a valid value for
'stream'.".
Whereas "ShapeLibrary" is name of assembly containing Embedded resources.
BaseShape is the user control in this Library in which I am putting image
from this perticular code above.
Have I missed anything?
Regards
Shailaja
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:Ok**************@TK2MSFTNGP10.phx.gbl... You can save your images as embedded resources and put them into the
picturebox by loading them from a resource stream.
Put your images in the solution, set their build action to "Embedded
resource" and then to load them use;
picBox.Image=Image.FromStream(this.GetType().Assem bly.GetManifestResourceStr eam("<nameofassembly>.<nameofimage>");
--
Bob Powell [MVP]
C#, System.Drawing
The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
Read my Blog at http://bobpowelldotnet.blogspot.com
"Shailaja Kulkarni" <cr*********@hotpop.com> wrote in message
news:Og**************@TK2MSFTNGP10.phx.gbl... hi All,
This problem is for C# windows application.
I have a user control whcih contains one picture box along with other
controls.
Depending on certain conditions I want to change images on the picturebox. But at the same time I want to refer only assembly of the user control in other solution.
If I am using method System.Drawing.Image.FromFile("filename") I have
to put gif files containing those images in bin directory of solution in
whcih I am using user control.
But I don't want that.
I want that only assebly needs to be referenced.
Is there any way for this.
If yes please send code snipet.
Thanks
Shailaja