Wpf Browser Application and resources problem

M

Marek Kolesar

Hi ...

i develop now Wpf Browser Application ... now i have very ease web app ...

i have only 1 page wit h 2 buttons ....
in resources added file languages.xml
resources acces modifier set to public

and now my problem ....

how to load this resource ?

i try a few function .. but everytime functions return null

System.IO.Stream stream =
this.GetType().Assembly.GetManifestResourceStream("MyApp.Languages.xml");
System.IO.Stream stream1 =
this.GetType().Assembly.GetManifestResourceStream("../Languages.xml");
System.IO.Stream stream2 =
Application.ResourceAssembly.GetManifestResourceStream("Languages.xml");

+ everytime return null ... without exception ...

any idea whats wrong ?
 
N

Nicholas Paldino [.NET/C# MVP]

Marek,

By resource, what do you mean? I ask because WPF allows for embedding
resources within XAML files, and you could actually embed XML in the XAML
file as a resource.

Or is this a resource file that you are adding to the project, and then
acessing that? If this is the case, then the designer should have added a
type-safe wrapper to access the resource through.

Or are you just adding the file to the project and setting the Build
Action to "Embedded Resource"? If this is the case, then the first call
should work, assuming that the default namespace for your app is "MyApp".
You need to check the properties for the project and on the Application tab,
look at the "Default Namespace" as that is what needs to preceed
"Langages.xml".
 
M

Marek Kolesar

tx ...

i put file into resources ( resources is embedeed resources) ( click on
resources -> add reseurce ..and inset file ..)

i try debug ... all data from languages .xml is in *.deploy file ...

but .. Resources.Count = 0;
then i try App.Resources ... same ... not here ...
+ i try locate this resource in debuger ... i read all property ... and
never get my resource .... everytime return null

+ namespaces have corect

or if u have link for sample how to use resources in Wpf Browser Application
.... then i try compare whats wrong ..

----------------------------------------------------------------------------------------------------------------------------------


Nicholas Paldino said:
Marek,

By resource, what do you mean? I ask because WPF allows for embedding
resources within XAML files, and you could actually embed XML in the XAML
file as a resource.

Or is this a resource file that you are adding to the project, and then
acessing that? If this is the case, then the designer should have added a
type-safe wrapper to access the resource through.

Or are you just adding the file to the project and setting the Build
Action to "Embedded Resource"? If this is the case, then the first call
should work, assuming that the default namespace for your app is "MyApp".
You need to check the properties for the project and on the Application
tab, look at the "Default Namespace" as that is what needs to preceed
"Langages.xml".

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marek Kolesar said:
Hi ...

i develop now Wpf Browser Application ... now i have very ease web app
...

i have only 1 page wit h 2 buttons ....
in resources added file languages.xml
resources acces modifier set to public

and now my problem ....

how to load this resource ?

i try a few function .. but everytime functions return null

System.IO.Stream stream =
this.GetType().Assembly.GetManifestResourceStream("MyApp.Languages.xml");
System.IO.Stream stream1 =
this.GetType().Assembly.GetManifestResourceStream("../Languages.xml");
System.IO.Stream stream2 =
Application.ResourceAssembly.GetManifestResourceStream("Languages.xml");

+ everytime return null ... without exception ...

any idea whats wrong ?
 

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

Top