Which is better for getting assembly location , GetAssembly().Location or GetExecutingAssembly().Location

后端 未结 2 1246
无人共我
无人共我 2020-12-15 05:36

Please suggest which is the best to getting executing assembly location.

Assembly.GetAssembly(typeof(NUnitTestProject.RGUnitTests)).Location
<
2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 06:15

    It seems rather obvious: When you want the executing assembly, use GetExecutingAssembly.

    Sometimes you don't have one, for example when running as an Office add-in. You could use Assembly.GetAssembly instead.

提交回复
热议问题