Resources assemblys and csc.exe

D

dgauchet

Hi all,

I would build a resources assembly using csc.exe.
I launched :
csc.exe /out:MyDll.dll /target:library /res:.\..\Main.resx
But now, I'm trying to include some namespaces in my assembly to hierarchize
my resources.
So I tried a lot of combination as :
csc.exe /out:MyDll.dll /target:library /res:.\..\Main.resx
/res:\..\MyNamespaceFolder\Main.resx,MyNamespaceFolder\Main.resx
or
csc.exe /out:MyDll.dll /target:library /res:.\..\Main.resx
/res:\..\MyNamespaceFolder\Main.resx,MyNamespaceFolder/Main.resx
or
csc.exe /out:MyDll.dll /target:library /res:.\..\Main.resx
/res:\..\MyNamespaceFolder\Main.resx,MyNamespaceFolder.Main.resx

and each time my assembly is compiled without error but contains either
MyNamespaceFolder\Main.resx or MyNamespaceFolder/Main.resx or
MyNamespaceFolder.Main.resx in the root namespace.

Is somebody knows how could I do to resolve my problem?

Thanks a lot.

D.
 
D

dgauchet

Sorry!!

I was wrong, it doesn't works at all!!
Actually, my Ids are very similar to my Values so, I believed it was OK
without Namespaces...

So, I would be very grateful if somebody knows what I am doing wrong.

Thanks.
 
R

Richard Grimes [MVP]

dgauchet said:
Hi all,

I would build a resources assembly using csc.exe.
I launched :
csc.exe /out:MyDll.dll /target:library /res:.\..\Main.resx

To use ResourceManager you have to compile the resx file and add that as
a resource. What you have done is added the resx XML as a resource, and
to read that you have to use Assembly.GetManifestResourceStream and then
interpret the XML yourself. This is not too much of a problem because
the data in the XML is usually text or a serialized object, but you have
to know how to interpret it.

Instead, I assume you want to add the resource and use ResourceManager,
which will do the deserialization for you. To do that compile the resx
file to a resources file using resgen. (This is a smart tool, it will
compile .txt and .resx files to .resources files and decompile
..resources files.)

Here's a complete explanation of .NET resources:

http://www.grimes.demon.co.uk/workshops/fusWSNine.htm

Richard
 
D

dgauchet

Thanks Richard.

Effectively, I had to generate my .resources files using ResGen.exe (or
CFResGen.exe for compact applications) and to link these files in my
assembly using AL.exe
It works fine!!

Example:
CFResGen /compile A.resx B.resx
A.resources and B.resources were generated
AL /out:MyProject.dll /embed:A.resources,MyProject.A.resources
/embed:B.resources,MyProject.B.resources
MyProject.dll was created

Note that you need to add your project's name in the logical name of your
..resources files if you want to retrieve your resources at the running time.

D.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top