In C#, how do you reference types from one in-memory assembly inside another?

后端 未结 2 986
南笙
南笙 2021-01-06 07:12

The example program below compiles two in-memory assemblies. The first compilation works fine. The second one fails because it needs access to a class from the first assem

相关标签:
2条回答
  • 2021-01-06 07:52

    Define interfaces in a normal assembly and have classes in each generated assembly implement those interfaces. The generated assemblies will need a reference to the one containing the interfaces, not each other.

    0 讨论(0)
  • 2021-01-06 07:53

    Based on documentation found on MSDN and on the code in reflector that I looked at (for the compiler classes) it is not possible to do what you want. The reason is that underneath, the code compiler classes that you are using shell out to the actual compiler.

    Also, the code compiler classes are actually generating the temporary files underneath, and based on the code I looked at in reflector, they are not cleaning up the files. So based on that, I would say just generate the file on the disk in a temporary location, and then add reference to it.

    0 讨论(0)
提交回复
热议问题