Re: Loading string resource from a file
- From: "dev15" <dev15@xxxxxxxxx>
- Date: Thu, 5 Jul 2007 17:05:43 +0100
Thanks Chris, i got it working use VB version of your code below.
But how do i use the TypeSafe wrapper where is this?
"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
news:uqxuAexvHHA.3500@xxxxxxxxxxxxxxxxxxxxxxx
None of the "My" namespace exists in the Compact Framework - largely
because it doesn't provide anything that can't be gotten through other
calls.
Studio 05 projects can create a resource file directly for a project (in
project properties) or you can add them manually. It will then generate a
typesafe wrapper for each string in the file (unless you turn off the
external tool that does it).
If you use the typesafe wrapper, you don't need to use the
ResourceManager. If you find that the wrapper doesn't meet your needs
(which certainly can be the case) then you use something like this
(namespaces and assembly manes will likely be different for you):
This assumes all string resources are in a separate assembly called
Customer.Globalization.dll
Assembly asm = Assembly.Load("MyCustomer.Globalization");
m_rm = new ResourceManager("MyCustomer.Globalization.Strings", asm);
....
public static string GetString(string name, CutureInfo culture)
{
return m_rm.GetString(name, culture);
}
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
"dev15" <dev15@xxxxxxxxx> wrote in message
news:OqkSM$vvHHA.3356@xxxxxxxxxxxxxxxxxxxxxxx
Thanks for the reply, i'm using VS2005 and VB.NET Compact Framework
Version 1 Service Pack3. Is the My object available in CF 1 SP3?
I've created a very basic PocketPC app with 1 form with a label on. I've
have
a resource file with a single string in.
Me.Label1.Text = My.Resources.Welcome
The intellisense doesn't recognise My.
"Simon Hart" <srhartone@xxxxxxxxx> wrote in message
news:D1B48DB7-3954-4199-A225-ADA6FCC2C6F6@xxxxxxxxxxxxxxxx
You are using VB.NET and VS 2005 aren't you? Have you also read this:
http://msdn2.microsoft.com/en-us/library/6wkcc526(VS.80).aspx
You shouldn't have to import anything, it should just work.
I'm not a VB developer nor do I have VB.NET installed so I can't check
on my
machine but the above link explains it all.
--
Simon Hart
http://simonrhart.blogspot.com
"dev15" wrote:
The intellisense does not recognise My. in my project do i need
to import anything library or something.
"Simon Hart" <srhartone@xxxxxxxxx> wrote in message
news:D30B5897-C52D-4B01-982A-40FFFB512A2B@xxxxxxxxxxxxxxxx
With VS2005 you shouldn't have to work directly with the
ResourceManager
class. I could tell you how, but you haven't have to so I'll help you
get
the
new feature in VS 2005 working.
I don't have VB installed as I don't use it but if you right click
your
project, then click the Resource tab, this should enable you to add
strings,
images etc. Again, nit sure how this works for localized resources,
but
doing
this should add a default resx file to your project.
To access the strongly typed class as a result from the above, I
believe
in
VB you need to use the My.Resources object.
See here for more info:
http://msdn2.microsoft.com/en-us/library/dhs35kds(VS.80).aspx
My.Resources is covered here:
http://msdn2.microsoft.com/en-us/library/6wkcc526(VS.80).aspx
--
Simon Hart
http://simonrhart.blogspot.com
"dev15" wrote:
VS2005
"Simon Hart" <srhartone@xxxxxxxxx> wrote in message
news:CE73BA81-69A5-4E4A-AD1A-ECCF9B18FA79@xxxxxxxxxxxxxxxx
What version of Visual Studio are you using?
--
Simon Hart
http://simonrhart.blogspot.com
"dev15" wrote:
Also i forgot to mention i am using CF V1.0 SP3 if that makes a
difference
"Simon Hart" <srhartone@xxxxxxxxx> wrote in message
news:D5F22943-C665-4A0C-B59F-626D230775FC@xxxxxxxxxxxxxxxx
The best way if using VS 2005 is to move the Resources.resx
file
(any
any
other language resources) to the Properties folder under your
project.
VS
will then create a wrapper class which enables you to access
the
resources
via strongly typed properties.
ie for a string resource:
string myErrorMessage =
Properties.Resources.FailedToInstallCabReturnCodeNotZero
This also works for icons, images etc...
So using this method you need not work directly with the
ResourceManager
class.
--
Simon Hart
http://simonrhart.blogspot.com
"dev15" wrote:
Hi, i am developing a vb localised app for Pocketpc 03 and
WM5.
I have resource files for German and English called
Resources.de.resx
and Resources.resx
I am trying to create a resource manager object :
LocalApp is my app namespace, However the code does not
compile
due to the rm = New ResourceManager("LocalApp.Resources",
Assembly.GetExecutingAssembly()))
statement. I also tried using My.Resources but that doesn't
pass
the
Intellisense checker.
I noticed my resources files are in a My Project folder which
the
wizard
generated, don't know
if this is causing an issue.
What is is the best way to access the resources in the
satellite
assemblies.
Public Shared Sub Main()
rm = New ResourceManager("LocalApp.Resources",
Assembly.GetExecutingAssembly()))
objFrmMain = New Form1
Application.Run(objFrmMain)
End Sub
.
- Follow-Ups:
- Re: Loading string resource from a file
- From: Simon Hart
- Re: Loading string resource from a file
- References:
- Re: Loading string resource from a file
- From: dev15
- Re: Loading string resource from a file
- From: Simon Hart
- Re: Loading string resource from a file
- From: dev15
- Re: Loading string resource from a file
- From: Simon Hart
- Re: Loading string resource from a file
- From: dev15
- Re: Loading string resource from a file
- From: Simon Hart
- Re: Loading string resource from a file
- From: dev15
- Re: Loading string resource from a file
- From: <ctacke/>
- Re: Loading string resource from a file
- Prev by Date: Re: General Network Error
- Next by Date: Calculating height of word-wrapped Label control
- Previous by thread: Re: Loading string resource from a file
- Next by thread: Re: Loading string resource from a file
- Index(es):
Relevant Pages
|