简体   繁体   English

如何在VB6程序中使用ReportViewer VB.net DLL?

[英]How to use ReportViewer VB.net DLL in VB6 program?

I've written a DLL that provides methods for extracting data from a MySQL DB and generating a report using the built-in report viewer in VS 2012. The idea is to use this in a VB6 program. 我编写了一个DLL,该DLL提供了从VS 2012中使用内置报表查看器从MySQL数据库中提取数据并生成报表的方法。其想法是在VB6程序中使用它。 I've gone through the following process: 我经历了以下过程:

1) Build the DLL in VS with "register for COM interop" selected 1)在VS中构建DLL,并选择“注册COM互操作”

2) Placed the DLL and TLB file in the directory of the VB6 program on another machine 2)将DLL和TLB文件放在另一台计算机上的VB6程序的目录中

3) Used regasm: "regasm Report.dll /tlb: Report.tlb /codebase" (redundant step if I already have the TLB file generated by VS?) 3)使用过的regasm:“ regasm Report.dll /tlb:Report.tlb / codebase”(如果我已经有VS生成的TLB文件,则是多余的步骤?)

4) Added the TLB file to project references in VB6 4)将TLB文件添加到VB6中的项目引用中

The VB6 program builds and executes okay, but when I got to run my report I just get "Automation error: the system cannot find the file specified". VB6程序可以生成并执行,但是当我运行报表时,我只会看到“自动化错误:系统找不到指定的文件”。

I've gone through the above process for a trivial DLL according to the instructions given here . 根据这里给出的说明,我已经完成了上面有关琐碎DLL的过程。 This worked fine. 这很好。 I suspect that the references used in my DLL (MySQL.Data and Microsoft.ReportViewer.WinForms) may also need to be registered on the VB6 machine. 我怀疑在DLL中使用的引用(MySQL.Data和Microsoft.ReportViewer.WinForms)可能也需要在VB6计算机上注册。 I've been able to do this with MySQL.Data but not the ReportViewer DLL. 我已经可以使用MySQL.Data来执行此操作,但不能执行ReportViewer DLL。

If it makes a difference, the DLL was built on a Windows 7 64 bit machine whereas the VB6 machine runs XP 32-bit. 如果有所不同,则该DLL构建在Windows 7 64位计算机上,而VB6计算机则运行32位XP。

Thanks in advance. 提前致谢。

Turned out the problem was that I needed to set the Copy Local property for Microsoft.ReportViewer.Common and copy the relevant DLL files along with my own DLL. 原来的问题是,我需要为Microsoft.ReportViewer.Common设置“ 复制本地”属性,并复制相关的DLL文件以及我自己的DLL。 Hope this helps anyone with a similar problem. 希望这对遇到类似问题的人有所帮助。

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

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