WPF 资源插件

发布于 2024-08-08 23:54:58 字数 550 浏览 1 评论 0原文

我有一个 WPF 应用程序作为另一个应用程序中的加载项运行。 (在本例中,它是基于 COM 的,但我认为这对于我遇到的问题并不重要)

当我独立运行它时,该应用程序工作正常。作为加载项运行时,存在资源问题。

第一:(次要)

“pack:”uri 方案根本不可用。我可以解决这个问题,但最好能理解为什么(以及是否可以解决)

第二:(showstopper)

找不到 XAML 资源(找到了 XAML!)。错误消息表明 Assembly.GetEntryAssembly() 为 null(这是可以理解的),我应该设置 Application.ResourceAssembly。

问题是我的应用程序由 2 个程序集组成,它们都包含 XAML 和资源。我应该将哪一个设置为资源集合?我都尝试过,但都不起作用。 (错误消息只是说找不到资源)

找不到的资源是带有自动生成的静态类的普通文本。 XAML 如下所示:

I have a WPF application that runs as an add-in in another application.
(In this case it is COM based but I don't think it matters for the problem I have)

The application works fine when I run it standalone. When running as add-in there is a problem with resources.

First: (minor)

The "pack:" uri scheme is not available at all. I can work around this but it would be nice to understand why (and if it can be solved)

Second: (showstopper)

XAML resources can't be found (the XAML is found!). The errormessages says that Assembly.GetEntryAssembly() is null (which is understandable) and that I should set Application.ResourceAssembly.

The problem is that my application consists of 2 assemblies which both contain XAML and resources. Which one should I set as resource assembly? I have tried both and neither of them work. (The errormessage just says that the resource can't be found)

The resources that can't be found are normal text with an autogenerated static class. The XAML looks like:

<TextBox Text="{StaticResource my:Texts.ButtonText}">

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

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

发布评论

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