简体   繁体   English

替换 .NET 6 / .NET 核心中的过时 Assembly.CodeBase

[英]Replacement for obsolete Assembly.CodeBase in .NET 6 / .NET Core

We deploy a helper-executable along with our VSTO / Outlook AddIn via ClickOnce.我们通过 ClickOnce 与 VSTO / Outlook AddIn 一起部署了一个辅助可执行文件。

In the AddIn, we have a button which starts this helper-executable in a new process (it's needed because the AddIn runs as 32-bit / coupled with Outlook-bitness).在 AddIn 中,我们有一个按钮,可以在新进程中启动这个 helper-executable(它是必需的,因为 AddIn 以 32 位/加上 Outlook 位运行)。

Until now I managed it by using Assembly.CodeBase to get the path of the installed VSTO dll, where I also can find the helper-executable.到目前为止,我通过使用Assembly.CodeBase来管理它,以获取已安装的 VSTO dll 的路径,我还可以在其中找到帮助程序可执行文件。

I can not use Assembly.Location since this points to another cryptic cache-path where I can only find the current dll, not my installed bunch of dlls with helper-executable.我不能使用Assembly.Location ,因为它指向另一个神秘的缓存路径,我只能找到当前的 dll,而不是我安装的带有辅助可执行文件的 dll。

Now the problem: in .NET core / .NET 6, Assembly.CodeBase is obsolete, so how can I find my helper-executable in my outlook add-in?现在的问题是:在 .NET 核心/.NET 6 中, Assembly.CodeBase已过时,那么如何在我的 outlook 加载项中找到我的助手可执行文件?

Any other ideas, how to achieve that?还有其他想法,如何实现? Thanks in advance.提前致谢。

You need to check ClickOnce cache folder, the ApplicationDeployment.DataDirectory property returns the path to the ClickOnce data directory.您需要检查 ClickOnce 缓存文件夹, ApplicationDeployment.DataDirectory属性返回 ClickOnce 数据目录的路径。 But it is not available for.Net 6 (core).但它不适用于.Net 6(核心)。 See How to get folder path for ClickOnce application for other alternatives.有关其他替代方法,请参阅如何获取 ClickOnce 应用程序的文件夹路径

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

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