resx in dll

Discussion in 'ASP .Net' started by Alexander Widera, Aug 1, 2007.

  1. 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
     
    Alexander Widera, Aug 1, 2007
    #1
    1. Advertising

  2. 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
     
    Peter Bucher [MVP], Aug 1, 2007
    #2
    1. Advertising

  3. 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, Aug 1, 2007
    #3
  4. 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
     
    Jesse Houwing, Aug 1, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page