在 AddInProcess 中激活 AddInToken 时控制 AppDomainSetup

发布于 2024-07-24 09:29:51 字数 356 浏览 3 评论 0原文

在 .net 中,可以在新的 AppDomain 中创建 AddIn。 创建新的 AppDomain 并不是什么新鲜事,可以使用 AppDomainSetup 类来指定新创建的 AppDomain 的所有启动参数(例如在哪里找到 app.config)。 但是,当使用新的 AddInProcess(指定 AddIn 应在全新进程中实例化)激活 AddInToken 时,无法直接访问将用于在新进程中创建 AppDomain 的 AppDomainSetup 参数。

有什么办法可以做到这一点吗? 我确实需要能够强制我的新插件使用新的 app.config 设置以及 AppDomain 上的各种其他自定义设置。

感谢您在这里的任何帮助...

In .net, one can create an AddIn within a new AppDomain. The creation of new AppDomains is nothing new, and one can use an AppDomainSetup class to specify all the startup parameters (such as where to find the app.config) of the newly created AppDomain.
However, when activating an AddInToken using a new AddInProcess (which specifies that the AddIn should be instantiated within an entirely new process), one does not have direct access to the AppDomainSetup parameters that will be used to create the AppDomain within the new Process.

Is there ANY way to do this??
I really need to be able to force my new AddIns to use new app.config settings, and various other customizations on the AppDomain.

Thanks for any help here...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似最初 2024-07-31 09:29:51
var addins = AddInStore.FindAddIns(typeof(AddInHostView), addInRoot);
foreach (var addin in addins)
{
    var addinInstance = addin.Activate<AddInHostView>(AddInSecurityLevel.FullTrust);

    // snip
    // do stuff
    // snip
}

使用此代码(我知道 FullTrust 不好,但对于我的应用程序来说是必需的),我可以在每个目录中指定一个单独的 app.config (名称与 Addin 程序集相同)。

\AddIns
 \AddIn1
   AddIn1.dll
   AddIn1.dll.config
var addins = AddInStore.FindAddIns(typeof(AddInHostView), addInRoot);
foreach (var addin in addins)
{
    var addinInstance = addin.Activate<AddInHostView>(AddInSecurityLevel.FullTrust);

    // snip
    // do stuff
    // snip
}

With this code (I understand FullTrust is bad, but for my application is is needed) I am able to specify a seperate app.config (named the same as the Addin assembly) in each directory.

\AddIns
 \AddIn1
   AddIn1.dll
   AddIn1.dll.config
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文