Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Diffrent Resource Name in DesignTime and RunTime !

0 views
Skip to first unread message

Parham

unread,
Mar 8, 2005, 11:40:41 AM3/8/05
to
Hello All,
I have a solution with two projects: one MyProjectControls in C# and
another MyProject in VB.net.
I have some bitmaps that are Embeded in MyProjectControls project and
using them for my custom controls in MyProjectControls. The bitmaps are
in the "Image" folder of MyProjectControls.
I am using MyProjectControls custom controls in MyProject project.
I can get bitmaps with "Bitmap1.bmp" at design time but at runtime I
should use "MyProjectControls.Images.Bitmap1.bmp" istead of
"Bitmap1.bmp" ! Why?
I have not this problem in Full framework, Is this problem for CF?
In full framework I can get bitmaps at DesignTime and RunTime with same
name.

Thanks,
Parham

Tim Wilson UNDERSCORE AT PERIOD

unread,
Mar 8, 2005, 11:57:00 AM3/8/05
to
It all depends on the name used to compile that resource into the assembly.
I assume that you are using the Assembly.GetManifestResourceStream() method
to read the resource.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflectionassemblyclassgetmanifestresourcestreamtopic.asp

So I assume you have a design-time and run-time assembly for your custom
controls. Check the resource name, in both the design-time and run-time
assemblies, using ildasm to see if they line up.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptutorials/html/il_dasm_tutorial.asp

--
Tim Wilson
.Net Compact Framework MVP

"Parham" <parham.g...@gmail.com> wrote in message
news:1110300041.4...@z14g2000cwz.googlegroups.com...

Parham

unread,
Mar 8, 2005, 1:04:22 PM3/8/05
to
Tim,
I have checked those with ildsam and they are diffrent as I described
above.
But why?
I am compiling Design-Time assembly with csc command and Run-Time
assembly with the Build command in VS.net.

And another question about csc: We can use /out switch for multiple cs
files in this format : /out: "c:\project\outputfolder"
"c:\project\*.cs"
*.cs instead of all files names, but how to this with resources :
/res:"c:\projects\*.bmp" (this is not working ! and i should add all
files - about 100 - manually ! )

Parham

Tim Wilson UNDERSCORE AT PERIOD

unread,
Mar 8, 2005, 1:17:43 PM3/8/05
to
When you compile the resource into your design-time assembly ensure that you
are using the same resource name as will be created for your run-time
version (which should be <defaultnamespace>.<resourcename>, but if you have
a folder then the folder name will be in there as well). Add the following
line to the design-time csc command line build, and then check the
assemblies through ildasm.
/res:MyProjectControls.Images.Bitmap1.bmp

I haven't tried the "*" approach for resource files so I cannot confirm or
deny that it works. However, if it indeed does not work then you can always
write a small application that will build your command line and save it into
a batch file. You can have the app run through the appropriate folder,
locate all files with a .bmp extension and add the appropriate information
into a string that you will write out to a .bat file on completion.

--
Tim Wilson
.Net Compact Framework MVP

"Parham" <parham.g...@gmail.com> wrote in message

news:1110305061.9...@z14g2000cwz.googlegroups.com...

Alex Feinman [MVP]

unread,
Mar 8, 2005, 1:29:17 PM3/8/05
to
The resource name is generated by appending the resource file name to the
project default namespace. It is then specified in the csc command line as
csc /res:pic1.bmp,MyNamespace.pic1.bmp mysource.cs

--
Alex Feinman
---
Visit http://www.opennetcf.org


"Parham" <parham.g...@gmail.com> wrote in message

news:1110305061.9...@z14g2000cwz.googlegroups.com...

Parham

unread,
Mar 8, 2005, 2:14:29 PM3/8/05
to
If I set an identifire for resources in my design-time assembly :
/res:"c:\project\Images\Bitmap1.bmp","MyProjectControls.Images.Bitmap1.bmp"
it will be the same as my run-time assembly.
But I want resources names without Folder names. How I can do this in
VS for my run-time assembly? embed resources only with defaultnamespace
and resource name NOT Folder name?
My desktop solution (that has two project same as above project - but
both in VB.net) has no problem and all resources have the default
namespace and the resource name, WITHOUT Folder name.
Is this for C# projects that add Folder name in resource names?

Tim Wilson UNDERSCORE AT PERIOD

unread,
Mar 8, 2005, 2:29:58 PM3/8/05
to
Take the bmps out of the folder and place them in the same directory as the
project. What happens if you had a resource in the same folder as the
project with the name "MyBmp.bmp" and another resource in a folder called
"Images" with the name "MyBmp.bmp"? How would you know, when you load the
resource, which one is getting loaded if the folder name was ignored since,
theoretically, both would have the same resource name?

--
Tim Wilson
.Net Compact Framework MVP

"Parham" <parham.g...@gmail.com> wrote in message

news:1110309269.5...@z14g2000cwz.googlegroups.com...

Parham

unread,
Mar 8, 2005, 3:49:00 PM3/8/05
to
In a VB.net WindowsControlLibrary project if I had two resource with
the same name but in diffrent folders, This error will occur:

Resources 'Ticket\Ticket.Pay.NotPayed.gif' and
'Ticket\Images\Ticket.Pay.NotPayed.gif' have the same manifest resource
name 'MyProjectControlLibrary.Ticket.Pay.NotPayed.gif'.

VS.net does not allow resources with the same name but in diffrent
folders In a VB.net ControlLibrary Project, all of the resources should
have a unique name.

I'm naming the first of bitmaps with the name of my control,so they
have diffrent names and also they are in diffrent folders, But
resources in the compiled dll do not have The folder name in thier
names. These are for my VB.net Windows Control Library and I have no
problem with it. I can have a single function to get all bitmaps from
resources only with thier file names.

VB compiler generate resource name by appending the resource file name
to the project default namespace but C# compiler append Folder name to
the default namespace and then append resource file name to it.

Why? Can we change this ?

Parham

Tim Wilson UNDERSCORE AT PERIOD

unread,
Mar 8, 2005, 4:48:21 PM3/8/05
to
IMO, C# handles this correctly. It appears that VB.Net ignores folder names
when defining resource names, and C# does not. I do not know how to either
turn this off in C# or turn it on in VB.Net. This seems like one of those
incidents where VB is trying to do too much for the developer and is taking
away some flexibility. Here are some things to try. (1) Move your images
into the project folder (2) If that is not satisfactory, then try renaming
your images to include the folder name that C# would use so that the VB.Net
compiler sees this as part of the resource name.

--
Tim Wilson
.Net Compact Framework MVP

"Parham" <parham.g...@gmail.com> wrote in message

news:1110314940.8...@f14g2000cwb.googlegroups.com...

0 new messages