使用同一程序集的不同版本
我有一个项目,必须同时使用 ActiveReports 2 和 ActiveReports 6 中构建的报表。总体而言,它工作正常,但某些辅助程序集使用相同的名称。例如,为了能够导出为 PDF,两个版本都使用名为 ActiveReports.PdfExport.dll 的程序集。当然,相应的组件是不同的。
请注意,我不直接访问 ActiveReports.PdfExport.dll - 这是由 ActiveReports 运行时处理的。
我找不到将它们都包含到项目中的方法。有办法吗?广汽集团是答案吗?
I have a project where I simultaneously must use reports built in ActiveReports 2 and ActiveReports 6. Overall, it works ok, but some of the helper assemblies use the same name. For instance, to be able to export to PDF, both versions use an assembly called ActiveReports.PdfExport.dll. The corresponding assemblies are different, of course.
Note that I don't access the ActiveReports.PdfExport.dll directly - this is handled by the ActiveReports runtime.
I can't find a way to include both of them into the project. Is there a way? Is GAC the answer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为每个程序集创建单独的外部别名将会有所帮助如果有类型名称冲突。对于程序集名称冲突,请查看 ILMerge;您可以将所有相关组件组合在一起。您将为 ActiveReports 2 创建一个组合了所有所需程序集的程序集,并为 ActiveReports 6 创建另一个程序集。
Creating separate external aliases for each assembly will help if you have type name collisions. For assembly name collisions, take a look at ILMerge; you can combine all related assemblies together. You'd create an assembly for ActiveReports 2 that combines all its required assemblies and another for ActiveReports 6.
GAC 是一种方式,但 Fusion 解决方案具有很大的灵活性,可能就足够了。 Fusion 将在 BaseDirectory 中探测程序集名称 .[DLL|EXE]。如果没有找到,它将探测 BaseDirectory\Name.[DLL|EXE]\Name.[DLL|EXE]。因此,您可以在 Bin 文件夹中创建一个名为 ActiveReports.PdfExport.DLL 的文件夹并将旧版本的文件转储到其中。
GAC is one way, but Fusion resolution has a lot of flexibility in it that might suffice. Fusion will probe in the BaseDirectory for the assembly name .[DLL|EXE]. If not found it will probe BaseDirectory\Name.[DLL|EXE]\Name.[DLL|EXE]. So you might be able to get away with creating a folder named ActiveReports.PdfExport.DLL in your Bin folder and dumping the older version of the file in there.
是的,您必须将两者都放入 GAC(这就是它的用途,以防客户端程序集)。
我的想法:创建两个库帮助程序,将每个库引用到适当的程序集,将它们注册到某种工厂或管理器中,并在需要时调用特定的库帮助程序。
Yes, you have to put both into GAC (this is what it's made for, in case of client assemblies).
My idea: create two libraries-helpers, reference each to appropriate assembly, register them into some kind of factory or manager and call specific one when you need.