简体   繁体   English

如何部署不断变化的DLL?

[英]How to deploy a DLL that is constantly changing?

I have created several small applications that use my own DLL. 我创建了几个使用我自己的DLL的小应用程序。 The problem is, this DLL is constantly changing. 问题是,这个DLL不断变化。 My current solution to this problem is that I have a Setup project in the class library solution that creates and registers the DLL. 我目前解决这个问题的方法是,我在类库解决方案中有一个Setup项目,用于创建和注册DLL。 In all my applications I then have to open the solution and re-reference the newly created/registered DLL. 在我的所有应用程序中,我必须打开解决方案并重新引用新创建/注册的DLL。 Then I have to re-compile their setup projects, uninstall the old applications, and then re-install the new application. 然后我必须重新编译他们的安装项目,卸载旧的应用程序,然后重新安装新的应用程序。

There has to be a better way and I'm just not sure because I'm fairly new to all this. 必须有一个更好的方法,我只是不确定,因为我对这一切都很新。 I have looked into ClickOnce but I don't think that will solve my issue as I cannot publish a class library. 我已经查看了ClickOnce,但我认为这不会解决我的问题,因为我无法发布类库。 I have looked into checking version numbers but I must be doing something wrong because it doesn't work either. 我已经研究过检查版本号但我必须做错了,因为它也不起作用。

I understand that once a DLL is created and being used in an application it should essentially not be touched. 我知道,一旦创建了一个DLL并在应用程序中使用它,就不应该触及它。 I do not have that option in this situation. 在这种情况下我没有这个选择。 It is constantly updated. 它不断更新。 Done. 完成。

So, is there a better way? 那么,有更好的方法吗? A point in the direction of a guide or related question/answer/forum would be greatly appreciated. 我们将非常感谢指南或相关问题/答案/论坛的方向。

Edit : The DLL is not constantly changing during runtime but it is constantly evolving to allow more functionality and detail within the other applications. 编辑 :DLL在运行时不会不断变化,但它不断发展以允许其他应用程序中的更多功能和细节。 Also, one big thing I guess I should have mentioned is the Public interface is constantly chaning - usually adding new methods. 另外,我想我应该提到的一件大事是Public接口不断变通 - 通常会添加新方法。

Make sure the references to your DLL specify SpecificVersion=false. 确保对DLL的引用指定SpecificVersion = false。 Then just deploy each new version into the GAC and that should do the trick. 然后将每个新版本部署到GAC中,这应该可以解决问题。 Eventually, you can also manually force versions using Binding Redirection . 最后,您还可以使用“ 绑定重定向”手动强制实施版本。

您可以尝试的解决方案是为项目使用单个解决方案,并在需要的任何地方引用项目。

Check out NuGet 看看NuGet

You could set up an internal Nuget repository (really just a folder that stores nupkg files.) Then when you build a new DLL, you can update the apps as needed in studio. 您可以设置一个内部Nuget存储库(实际上只是一个存储nupkg文件的文件夹。)然后,当您构建新的DLL时,您可以根据需要在工作室中更新应用程序。 This would ensure it had the latest version. 这将确保它具有最新版本。 They shouldn't need a redployment unless there are bugs in the DLL that you're fixing. 除非您正在修复的DLL中存在错误,否则它们不应该需要重新部署。

One solution is as follows: 一种解决方案如下:

  • Physically separate the interface from the implementation. 物理上将接口与实现分开。 eg AssemblyA is the interface, the application (AssemblyB say) knows only the interface at compile time. 例如AssemblyA是接口,应用程序(AssemblyB说)在编译时只知道接口。 The implementation (AssemblyC) also knows/references AssemblyA of course. 实现(AssemblyC)当然也知道/引用AssemblyA。 The point being that AssemblyB does not reference AssemblyC. 关键是AssemblyB没有引用AssemblyC。 This will require you to use an IoC container (like MS Unity 2.0 but there are many others) in order to resolve and instantiate your concretes at runtime. 这将要求您使用IoC容器(如MS Unity 2.0,但还有许多其他容器),以便在运行时解析和实例化您的混凝土。
  • Write an update process that finds the new AssemblyC.dll, replaces the local copy and uses reflection along with the IoCContainer to 'load' the new implementation at what ever interval you require, typically app start up. 编写一个更新过程,找到新的AssemblyC.dll,替换本地副本,并使用反射和IoCContainer按照您需要的时间间隔“加载”新实现,通常是app启动。

The above relies on your interface being stable. 以上依赖于您的界面稳定。 If it isn't, you may be able to write a (more) stable Facade . 如果不是,您可以编写一个(更多)稳定的Facade

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

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