简体   繁体   English

csc.exe和相互依赖的程序集

[英]csc.exe and inter-dependent assemblies

I've been working on a project, and as it's grown I realize that two parts that cannot be joined together are inter-dependent. 我一直在研究一个项目,随着它的成长,我意识到两个不能连接在一起的部分是相互依赖的。

Let's call these two parts a.exe and b.dll. 我们将这两个部分称为a.exe和b.dll。 b.dll provides an implementation that allows a.exe to retrieve data, but I want it to be its own standalone assembly so that it can easily be changed out to make a.exe communicate with different data sources. b.dll提供了一个允许a.exe检索数据的实现,但我希望它是自己的独立程序集,以便可以轻松更改它以使a.exe与不同的数据源通信。

However, while a.exe is required to reference b.dll, b.dll requires several functions that are an inseparable part of a.exe. 但是,虽然需要a.exe来引用b.dll,但b.dll需要多个函数,这些函数是a.exe不可分割的一部分。

Since I've been compiling -- to test -- as I've been writing this project, a.exe and b.dll both exist, and I can compile b.dll against a.exe and a.exe against b.dll, but how would/can I ever rebuild both of these from source? 因为我一直在编译 - 测试 - 因为我一直在编写这个项目,a.exe和b.dll都存在,我可以针对a.exe编译b.dll而针对b.dll编译a.exe ,但我怎么能/可以从源头重建这两个?

I would refactor your system into three assemblies: 我会将你的系统重构为三个程序集:

  • a.exe - Main EXE nothing should reference this a.exe - 主EXE什么都不应该引用这个
  • b.dll - As you have it today, but does not reference a.exe, it references c.dll b.dll - 正如您今天所拥有,但不引用a.exe,它引用了c.dll
  • c.dll - This should contain the common pieces / parts that both a and b need to reference c.dll - 这应该包含a和b都需要引用的常见部分/部分

In general, it would be a good idea to refactor this, and move the shared dependencies into their own assembly (c.dll). 通常,重构它并将共享依赖项移动到它们自己的程序集(c.dll)中是一个好主意。 This way, both a.exe and b.dll could reference c.dll, and you'd avoid this circular dependency. 这样,a.exe和b.dll都可以引用c.dll,并且你会避免这种循环依赖。

调用csc.exe,将a.exe和b.dll的源代码编译成a.exe,调用csc.exe,将b.dll的源代码编译成b.dll并引用a.exe,然后调用csc.exe上次,将a.exe的源代码编译成a.exe并引用b.dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM