PC Review


Reply
Thread Tools Rate Thread

How to change the namespace of embedded image

 
 
babylon
Guest
Posts: n/a
 
      9th Dec 2003
I have a user control (usercontrol.dll) that has an embedded image (abc.bmp)

I would like other project include the user control directly instead of
referencing the usercontrol.dll so that i only need to distribute one .exe
instead of both usercontrol.dll and the .exe

i use
// Get the assembly that contains the bitmap resource
Assembly myAssembly = Assembly.GetAssembly(assemblyType);
// Get the resource stream containing the images
Stream imageStream =
myAssembly.GetManifestResourceStream("UserControl.abc.bmp");
to get the abc.bmp

however if i include all the .cs / .bmp of the usercontrol project to other
project (e.g. TestProject)
the namespace of the bitmap would than changed to "TestProject.abc.bmp",
so the GetManifestResourceStream call fails...

How can i embedded an image and distribute the source code for compile in
order to provide single .exe output at the same time!?!??

thx...


 
Reply With Quote
 
 
 
 
Max
Guest
Posts: n/a
 
      9th Dec 2003
I had a similar problem and found out, using disassembler that the name of
embedded resource is formed by the visual studio as follows.

DefaultNamespace.Filename.
DefaultNamespace is the one you set up in project properties window. (Right
click on project name in SolutionExplorer and select Properties.)

Try to set it to empty string. Probably that will solve your problem.
You will hopefully be able to write GetManifestResourceStream("abc.bmp"); in
both projects.

Disassembler is Ildasm.exe tool. You might want to play with it to get to
know what happens in your assembly after compilation. At least it helped me
to understand a few things.

One more point.

When you add files from another directory to the project they will be copied
to the current directory. If you do not want them to be copied you can
manually edit the *.csproj file in notepad.

But, if, for example you have your embedded resource located in
resources\abc.bmp. It will be called DefaultNamespace.resources.abc.bmp in
the assembly.

One more important thing, you probably already noticed. Case matters.
"Abc.bmp" and "abc.bmp" is not one the same.






"babylon" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I have a user control (usercontrol.dll) that has an embedded image

(abc.bmp)
>
> I would like other project include the user control directly instead of
> referencing the usercontrol.dll so that i only need to distribute one .exe
> instead of both usercontrol.dll and the .exe
>
> i use
> // Get the assembly that contains the bitmap resource
> Assembly myAssembly = Assembly.GetAssembly(assemblyType);
> // Get the resource stream containing the images
> Stream imageStream =
> myAssembly.GetManifestResourceStream("UserControl.abc.bmp");
> to get the abc.bmp
>
> however if i include all the .cs / .bmp of the usercontrol project to

other
> project (e.g. TestProject)
> the namespace of the bitmap would than changed to "TestProject.abc.bmp",
> so the GetManifestResourceStream call fails...
>
> How can i embedded an image and distribute the source code for compile in
> order to provide single .exe output at the same time!?!??
>
> thx...
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded resource without leading namespace? Bernd S Microsoft Dot NET Framework 0 14th Dec 2006 06:19 PM
Embedded Image in HTML Email Using <IMG SRC="cid:My-Image =?Utf-8?B?QWxlY1I=?= Microsoft Outlook Discussion 4 19th Mar 2006 08:27 PM
Embedded resource namespace Jason Pettys Microsoft VB .NET 4 1st Jul 2005 07:46 AM
How to get embedded resources from any namespace in project? =?Utf-8?B?RWQ=?= Microsoft Dot NET Framework Forms 0 25th Jan 2005 12:27 AM
Embedded word doc changed to image-need to change back to word. =?Utf-8?B?Y2Zsb3Jlcw==?= Microsoft Excel Misc 0 23rd Jan 2005 07:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:07 PM.