删除对子类 DLL 的依赖

发布于 2024-11-18 10:39:12 字数 759 浏览 2 评论 0原文

(这个问题的上下文特定于 XNA,但原则是通用的。)

我有一个项目 A,其中包含扩展 Microsoft.Xna 的 Game 类。框架.游戏。项目A是一个类库并输出一个DLL。

然后,我有一个项目 B,它扩展了 A.Game 类并引用了 A.dll。当我尝试编译 B 时,出现此错误:

The type 'Microsoft.Xna.Framework.Game' is defined in an assembly that is not referenced. You must add a reference to assembly [...]

我不明白为什么会出现这种情况; B 仅依赖于 A,而 A 内部依赖于 Xna。是因为A.Game是子类吗?有没有办法消除这种依赖性要求?

我的目标是让 A 自行出版;它只输出一个DLL,任何项目都引用它;最终用户(开发人员)不需要它内部使用的任何内容。

我还在传递依赖项上检查了这个问题,但我没有公开A.Game 中的任何字段——仅是子类。

(The context of this question is specific to XNA, but the principle is general.)

I have a Project A with a Game class that extends Microsoft.Xna.Framework.Game. Project A is a class library and outputs a DLL.

I then have a project B that extends the A.Game class and has a reference to A.dll. When I try and compile B, I get this error:

The type 'Microsoft.Xna.Framework.Game' is defined in an assembly that is not referenced. You must add a reference to assembly [...]

I don't understand why this is the case; B only depends on A, which internally depends on Xna. Is it because A.Game is a subclass? Is there a way to remove this dependency requirement?

What I'm aiming for is to make A self-publishing; it outputs only one DLL, and any project references it; whatever it uses internally isn't required by end-users (developers).

I also checked out this question on transitive dependencies, but I don't expose any fields in A.Game yet -- only subclass.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏末的微笑 2024-11-25 10:39:12

没有办法避免这种情况。您无法将 Xna 库静态链接到 A,因此这意味着为了让 A 运行,您还需要可用的 Xna dll。请注意,您可以单独发布 A,然后告诉 A 的任何用户他们也需要 Xna dll,但这就是您能做的最好的事情。

想象一下你有 A,但没有 Xna dll。如何实例化 Game 类?它是 Xna dll 中包含的 Type 的子类,因此这意味着它的基本构造函数也在该 dll 中。

There's no way to avoid this. You cannot statically link the Xna library into A, so that means that in order for A to run, you need the Xna dll available as well. Note that you can publish A on its own and then tell any users of A that they need the Xna dll as well, but that's about the best you can do.

Image you had A, but no Xna dll. How could you instantiate the Game class? It's a subclass of a Type that is contained in the Xna dll, so that means it's base constructor is also in that dll.

轮廓§ 2024-11-25 10:39:12

您还需要在 B 中添加对 XNA 框架的依赖项。

You need to add in B a dependency to the XNA Framework as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文