Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   resx in dll (http://www.velocityreviews.com/forums/t526266-resx-in-dll.html)

Alexander Widera 08-01-2007 05:52 PM

resx in dll
 
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


Peter Bucher [MVP] 08-01-2007 07:38 PM

Re: resx in dll
 
Hi Alexander

> 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?

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

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET


Jesse Houwing 08-01-2007 08:28 PM

Re: resx in dll
 
Hello Peter Bucher [MVP],

> Hi Alexander
>
>> 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?
>>

> 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



Jesse Houwing 08-01-2007 08:38 PM

Re: resx in dll
 
Hello Peter Bucher [MVP],

> Hi Alexander
>
>> 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?
>>

> 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




All times are GMT. The time now is 10:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.