COM+ 的本地化组件

发布于 2024-12-22 05:31:24 字数 682 浏览 6 评论 0原文

我的解决方案中有两个项目:

  • ClassLibrary1(类库),其中包含
    • Class1,具有公共方法:公共共享函数 GetMyValue() As String 返回 My.Resources.MyResource.MyVariable End 功能
    • 两个资源文件 - MyResource.resx 和 MyResource.de.resx,它们都包含一个名为 myVariable 的字符串资源,其值为 “default”(在 MyResource.resx 中)和“de”(在 MyResource.de.resx 中)。
  • TempLocalization 项目(Windows 窗体),只有一个窗体和 OnLoad 事件处理程序。

代码:

Thread.CurrentThread.CurrentUICulture = New CultureInfo("de")
MessageBox.Show(Class1.GetMyValue())

当我运行该项目时,显示正确的值,即“de”。但是,当我设置 ClassLibrary1 项目的“使程序集 COM 可见”选项并将其安装到 COM+ 环境中时,这不再起作用 - MessageBox 显示值“默认”。

如何正确本地化我的 COM+ 程序集?

I have two projects in my solution:

  • ClassLibrary1 (Class Library), which contains
    • a class Class1, with a public method: Public Shared Function
      GetMyValue() As String Return My.Resources.MyResource.MyVariable End
      Function
    • Two resource files - MyResource.resx and MyResource.de.resx, both of them contain a string resource named myVariable with the value
      'default' (in MyResource.resx) and 'de' (in MyResource.de.resx).
  • TempLocalization project (Windows Forms), with only one form and the OnLoad event handler.

The code:

Thread.CurrentThread.CurrentUICulture = New CultureInfo("de")
MessageBox.Show(Class1.GetMyValue())

When I run the project, the correct value is shown, which is "de". But when I set the ClassLibrary1 project's 'Make assembly COM-visible' option and install it into COM+ environment, then this doesn't work anymore - the MessageBox displays the value "default".

How can I correctly localize my COM+ assembly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文