简体   繁体   English

C#MAF激活加载项而不锁定dll

[英]C# MAF Activate AddIn without locking dll

Using System.AddIn, is there a way to load and activate an AddIn without locking the .dll file? 使用System.AddIn,有没有一种方法可以在不锁定.dll文件的情况下加载和激活AddIn? I want to delete or override the file to load a new version of my AddIn. 我想删除或覆盖文件以加载我的AddIn的新版本。

The only way to unlock the file at this moment is shutting down the AddIn. 此时解锁文件的唯一方法是关闭AddIn。 But I need to keep it always alive for incoming calls (Async-service, yes, a nightmare). 但是我需要让它始终保持来电状态(异步服务,是的,噩梦)。

Or maybe there's another way to update AddIns at runtime, and I'm not doing it right. 也许还有另一种在运行时更新AddIns的方法,但我做的不正确。 I'd like to know wich can be the correct way to do this. 我想知道wich是执行此操作的正确方法。 Thanks! 谢谢!

What about the ShadowCopy functionality of the System.AppDomain class? System.AppDomain类的ShadowCopy功能如何?

I haven't given it a try yet, but you could try the following: 我还没有尝试过,但是您可以尝试以下方法:

  1. Create an AppDomainSetup . 创建一个AppDomainSetup
  2. In the AppDomainSetup instance set ShadowCopyFiles to true. 在AppDomainSetup实例中,将ShadowCopyFiles设置为true。
  3. In the AppDomainSetup instance set ShadowCopyFilesDirectories to the directory path(s) that contain the assemblies you want to be able to ovewrite at run time. 在AppDomainSetup实例中,将ShadowCopyFilesDirectories设置为目录路径,该目录路径包含您希望能够在运行时进行写操作的程序集。 This could simply be the directory where the add-in assembly is located. 这可能只是外接程序集所在的目录。 You should experiment a bit. 您应该尝试一下。
  4. In the AppDomainSetup instance set everything else according to your needs. 在AppDomainSetup实例中,根据需要设置其他所有内容。
  5. Use this overload of AppDomain.CreateAppDomain to create the new application domain. 使用AppDomain.CreateAppDomain的此重载来创建新的应用程序域。
  6. Load the add-in using this overload of AddInToken.LoadAddIn 使用此AddInToken.LoadAddIn重载加载加载项

You can find more info on shadow copying here . 您可以在此处找到有关卷影复制的更多信息。 Also read this thread at System.AddIn Tools and Samples page at CodePlex. 也可以在CodePlex的System.AddIn工具和示例页面上阅读此线程。

Once you load the new version, how would you expect handover to work? 加载新版本后,您如何期望切换工作?

Sounds like you need two add-ins: one (that you never change) to just receive and buffer incoming calls, and another (that you do change) to do the work of processing those calls. 听起来您需要两个外接程序:一个(您从未更改)仅接收和缓冲传入的呼叫,另一个(您确实更改)来处理这些呼叫。 Then you can shut down and upgrade the processing add-in. 然后,您可以关闭并升级处理加载项。 The message-receiving add-in meanwhile can buffer the async calls until the new version of the processing add-in is up and running. 同时,接收消息的加载项可以缓冲异步调用,直到新版本的处理加载项启动并运行为止。

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

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