How do I get the path of the assembly the code is in?

前端 未结 30 2770
小蘑菇
小蘑菇 2020-11-21 16:17

Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code.

<
30条回答
  •  不知归路
    2020-11-21 16:48

    I suspect that the real issue here is that your test runner is copying your assembly to a different location. There's no way at runtime to tell where the assembly was copied from, but you can probably flip a switch to tell the test runner to run the assembly from where it is and not to copy it to a shadow directory.

    Such a switch is likely to be different for each test runner, of course.

    Have you considered embedding your XML data as resources inside your test assembly?

提交回复
热议问题