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...
>
>
|