Ive written a DLL in VB.NET and I am trying to use it in a VB6 application. When I run the application from either directly in VB6 or from the executable I get the following error message:
"Class does not support automation or does not support expected interface."
Heres a snapshot of the DLL code:
Ive checked the "Register for COM Interop" property of the DLL and added the AssemblyKeyFile line to the AssemblyInfo.vb
In the VB6 application Ive added the DLL to the references. Heres a sample of the VB6 code:
The bold line above is the one giving the error. When I type in the lines that reference the DLL the intellisense works.
So what am I doing wrong?
"Class does not support automation or does not support expected interface."
Heres a snapshot of the DLL code:
Code:
Option Explicit On
Imports System
Imports Microsoft.Win32
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Security.Permissions
Imports System.Text
Imports CrystalDecisions.Enterprise
Imports CrystalDecisions.Enterprise.Viewing
Imports CrystalDecisions.Enterprise.Desktop.Report
Imports CrystalDecisions.ReportAppServer.Controllers
Imports CrystalDecisions.ReportAppServer.ClientDoc
Imports CrystalDecisions.ReportAppServer.DataDefModel
Imports CrystalDecisions.CrystalReports.TemplateEngine
Imports CrystalDecisions.ReportAppServer.ReportDefModel
Imports CrystalDecisions.ReportAppServer.CommonObjectModel
Imports CrystalDecisions.ReportAppServer.ObjectFactory
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Enum ReportServer As Integer
Development = 0
Test = 1
Production = 2
End Enum
Public Enum DocumentType As Integer
PDF = 0
MSWord = 1
MSExcel = 2
End Enum
<GuidAttribute("A366D469-A20A-4224-ACBA-6BDFE219E34A")> _
Public Interface _IBusinessObjectsServer
Function RetrieveRepositoryReport(ByVal pReportName As String, _
ByVal Server As ReportServer, _
ByRef pParamList(,) As String, _
ByVal DBUserName As String, _
ByVal DBPassword As String, _
Optional ByVal SQLServer As String = "", _
Optional ByVal Database As String = "") As ReportClientDocument
Sub ViewRepositoryReport(ByVal pReportName As String, _
ByVal Server As ReportServer, _
ByRef pParamList(,) As String, _
ByVal DBUserName As String, _
ByVal DBPassword As String, _
Optional ByVal SQLServer As String = "", _
Optional ByVal Database As String = "")
Function ExportRepositoryReport(ByVal pReportName As String, _
ByVal Server As ReportServer, _
ByRef pParamList(,) As String, _
ByVal DBUserName As String, _
ByVal DBPassword As String, _
ByVal pPathAndFilename As String, _
ByVal pDocumentType As DocumentType, _
Optional ByVal SQLServer As String = "", _
Optional ByVal Database As String = "") As Boolean
End Interface
<System.Runtime.InteropServices.ProgId("BusinessObjectsReportServer"), _
ClassInterface(ClassInterfaceType.None), _
GuidAttribute("E1A6A3DF-6843-4899-BB35-5FB782F90056")> _
Public Class BOEReportServer
Implements _IBusinessObjectsServer
Friend bolShowExportButton As Boolean = False
Friend bolShowGroupTreeButton As Boolean = False
Friend bolDisplayGroupTree As Boolean = False
Friend bolEnableDrillDown As Boolean = False
Friend bolShowRefreshButton As Boolean = False
Property ShowGroupTreeButton() As Boolean
Get
Return bolShowGroupTreeButton
End Get
Set(ByVal Value As Boolean)
bolShowGroupTreeButton = Value
End Set
End Property
Property ShowExportButton() As Boolean
Get
Return bolShowExportButton
End Get
Set(ByVal Value As Boolean)
bolShowExportButton = Value
End Set
End Property
Property DisplayGroupTree() As Boolean
Get
Return bolDisplayGroupTree
End Get
Set(ByVal Value As Boolean)
bolDisplayGroupTree = Value
End Set
End Property
Property EnableDrillDown() As Boolean
Get
Return bolEnableDrillDown
End Get
Set(ByVal Value As Boolean)
bolEnableDrillDown = Value
End Set
End Property
Property ShowRefreshButton() As Boolean
Get
Return bolShowRefreshButton
End Get
Set(ByVal Value As Boolean)
bolShowRefreshButton = Value
End Set
End Property
Public Function RetrieveRepositoryReport(ByVal pReportName As String, _
ByVal Server As ReportServer, _
ByRef pParamList(,) As String, _
ByVal DBUserName As String, _
ByVal DBPassword As String, _
Optional ByVal SQLServer As String = "", _
Optional ByVal Database As String = "") As ReportClientDocument Implements _IBusinessObjectsServer.RetrieveRepositoryReport
CODE REMOVED...
End Function
Public Sub ViewRepositoryReport(ByVal pReportName As String, _
ByVal Server As ReportServer, _
ByRef pParamList(,) As String, _
ByVal DBUserName As String, _
ByVal DBPassword As String, _
Optional ByVal SQLServer As String = "", _
Optional ByVal Database As String = "") Implements _IBusinessObjectsServer.ViewRepositoryReport
CODE REMOVED...
End Sub
Public Function ExportRepositoryReport(ByVal pReportName As String, _
ByVal Server As ReportServer, _
ByRef pParamList(,) As String, _
ByVal DBUserName As String, _
ByVal DBPassword As String, _
ByVal pPathAndFilename As String, _
ByVal pDocumentType As DocumentType, _
Optional ByVal SQLServer As String = "", _
Optional ByVal Database As String = "") As Boolean Implements _IBusinessObjectsServer.ExportRepositoryReport
CODE REMOVED...
End Function
End Class
Ive checked the "Register for COM Interop" property of the DLL and added the AssemblyKeyFile line to the AssemblyInfo.vb
In the VB6 application Ive added the DLL to the references. Heres a sample of the VB6 code:
Code:
Private Sub cmdReturnReport_Click()
On Error GoTo Err_cmdReturnReport_Click
Dim strParamList(5, 1) As String
Dim strReportName As String
strReportName = "EventsByPosition"
strParamList(0, 0) = "Area"
strParamList(0, 1) = "No"
strParamList(1, 0) = "Region"
strParamList(1, 1) = "No"
strParamList(2, 0) = "From-Date"
strParamList(2, 1) = "1995-01-01"
strParamList(3, 0) = "To-Date"
strParamList(3, 1) = "2004-12-31"
strParamList(4, 0) = "Event-Type"
strParamList(4, 1) = "J;V"
strParamList(5, 0) = "@Position"
strParamList(5, 1) = "EQUIPMENT MECHAN"
--------------------------------------------------------
- Display the report . . .
--------------------------------------------------------
Dim oRS As BusinessObjectsReportServer.BOEReportServer
[B]Set oRS = New BusinessObjectsReportServer.BOEReportServer[/B]
Call oRS.ViewRepositoryReport(strReportName, ReportServer_Development, strParamList, "HS50_Admin", "HS50_Admin")
Exit_cmdReturnReport_Click:
Exit Sub
Err_cmdReturnReport_Click:
MsgBox Err.Description & " - " & Err.Number
End Sub
The bold line above is the one giving the error. When I type in the lines that reference the DLL the intellisense works.
So what am I doing wrong?