resx in dll

  • Thread starter Alexander Widera
  • Start date
A

Alexander Widera

Hi,

i am developing a website and a dll .... in the App_GlobalResources
directory are some .resx-files.... which filename i know.
I want to use them in a dll which is in the bin-directory?

how can i do that?

thanks,
alex
 
J

Jesse Houwing

Hello Peter Bucher [MVP],
Hi Alexander

Mark "Build Action" in the Properties of the resx file to "Embedded
Resource".
You can seee a screenshoot of the propertie window here:
- http://aspnet.4guysfromrolla.com/articles/080906-1.aspx

I think what he's trying to do is to use the resources in the website project
in a project that is referenced by the website project.

So basically with a solution liek this:

+ solution
|- Project1
|- Website
|- References
| |- Project1
|- App_GlobalResources
|- Resource.Resx

And now he wants to access the resources in App_GlobalResources from sources
inside Project1.

The official word on this is that it cannot be done.

My guess is that using some creativity in the way you instantiate your resourcemanager
woudl actually get it to work, but I cannot guarantee that it will stay that
way.

The ResourceManager constructor get's an Assembly and a Resource name. For
the assembly try using Assebly.GetExecutingAssembly which with a bit of luck
resolves to the assembly in which the resource file was compiled. As name
for the resource... I'm not sure what the full name will be. You could try
using Lutz Roeder's Reflector to see how the compiler actually named it.
I'd guess something like 'WebSiteProjectsName.App_GlaobalResources.Resource.Resx.recource'.

From there you can use the GetString method of the Resource Manager to access
strings in the resource file.

A better solution would be to add a project to your solution which contains
the resources. Then use those resources from both the project and the website.

+ solution
|- ResourceProject
| |- Resource.Resx
|- Project1
| |- References
| | |- ResourceProject
|- Website
|- References
| |- Project1
| |- ResourceProject
|- App_GlobalResources

Jesse
 
J

Jesse Houwing

Hello Peter Bucher [MVP],
Hi Alexander

Mark "Build Action" in the Properties of the resx file to "Embedded
Resource".
You can seee a screenshoot of the propertie window here:
- http://aspnet.4guysfromrolla.com/articles/080906-1.aspx

I think what he's trying to do is to use the resources in the website project
in a project that is referenced by the website project.

So basically with a solution like this:

+ solution
|- Project1
|- Website
|- References
| |- Project1
|- App_GlobalResources
|- Resource.Resx

And now he wants to access the resources in App_GlobalResources from sources
inside Project1.

The official word on this is that it cannot be done.

My guess is that using some creativity in the way you instantiate your resourcemanager
woudl actually get it to work, but I cannot guarantee that it will stay that
way.

The ResourceManager constructor get's an Assembly and a Resource name. For
the assembly try using Assebly.GetExecutingAssembly which with a bit of luck
resolves to the assembly in which the resource file was compiled. As name
for the resource... I'm not sure what the full name will be. You could try
using Lutz Roeder's Reflector to see how the compiler actually named it.
I'd guess something like 'WebSiteProjectsName.App_GlaobalResources.Resource.Resx.recource'.

From there you can use the GetString method of the Resource Manager to access
strings in the resource file.

A better solution would be to add a project to your solution which contains
the resources. Then use those resources from both the project and the website.

+ solution
|- ResourceProject
| |- Resource.Resx
|- Project1
| |- References
| | |- ResourceProject
|- Website
|- References
| |- Project1
| |- ResourceProject
|- App_GlobalResources

Jesse
 

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top