在同一运行时运行两个相同的 DLL?
问题:我有 DLL 形式的开发代码和生产代码,我希望能够比较每个代码的结果。这一切都需要在同一运行时发生。
我正在寻找的内容:代码只需加载 dev DLL、存储结果,然后打开 prod DLL、存储结果,然后比较两者的结果。
当前策略:我现在正在考虑使用应用程序域,但我还没有找到任何非常清晰的代码示例来简单地展示如何加载 DLL、从该 DLL 运行方法,并存储该 DLL 的结果。应用程序域的概念对我来说仍然很模糊,因为它对于调用它的代码来说似乎非常外部,因此存储来自此类外部应用程序域的结果对我来说有点令人困惑。
无论如何,我真的对一个简单的示例感兴趣,该示例演示如何加载 DLL 并从中运行代码、存储结果以及加载同一 DLL 的另一个版本并执行相同的操作。
任何帮助将不胜感激!谢谢!
The problem: I have dev code and production code in DLL form and I want to be able to compare the results from each. This all needs to occur in the same run time.
What I'm looking for: Code that simply loads the dev DLL, stores the results, then opens the prod dll, stores the results, then compares the results from both.
Current Strategy: I'm thinking of using app domain right now, but I haven't been able to find any very clear code examples that simply show how to load a DLL, run a method from that DLL, and store the results from that DLL. The concept of app domains is still fuzzy to me as it seems very external to the code it's being called from so storing results from this sort of external app domain is a bit confusing for me.
In any case, I'd really be interested in a simple example demonstrating loading a DLL and running code from it, storing the results, and loading another version of the same DLL and doing the same thing.
Any help would be super appreciated! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您阅读这篇文章 。他们的示例使用 外部别名 指定同一 DLL 的两个不同版本。
在您的使用部分上方创建别名:
添加您的引用并为每个引用提供适当的别名。您可以在其属性中指定要与参考一起使用的别名:
一旦您设置了别名,您就可以可以做类似的事情:
I would recommend giving this article a read. Their example uses extern alias to specify two different versions of the same DLL.
Create the aliases above your using section:
Add your references and give each one the appropriate alias. You can specify what aliases to use with the Reference in it's properties:
Once you have the aliases in place you can do something like: