|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vb.net Automation Issues - COM Interoplibrary (using vs.net 2003), registering it for com interop and then invoking its functions from an object in VB6. The error I am receiving is happening in VB6 when I go to compile the project: Compile Error: Function or Interface marked as restricted, or the function uses an Automation type not supported in Visual Basic Here is my vb6 code, which is run from a button on a test form: Private Sub cmdInvoke_Click() On Error GoTo err_handler Dim obj As CommsClass.ClientInterface Set obj = New CommsClass.ClientInterface obj.Invoke Exit Sub err_handler: MsgBox Err & " - " & Error End Sub And here is my vb.net CommsClass code. This is the ONLY code I have in the project, and the project is registered for COM Interop. Public Class ClientInterface Public Function Invoke() As String MsgBox("Hi") End Function End Class Why would somthing so simply cause such an awkward error?! Thanks You have to make your classes visible to COM. Try the following code. Of
course, make sure you change the GUIDs by using the GUID generator utility. Imports System.Runtime.InteropServices <InterfaceType(ComInterfaceType.InterfaceIsIDispatch), _ Guid("A42C5454-6324-4be2-A7FE-A2868AE055DC")> _ Public Interface _ClientInterface <DispId(1)> Sub Invoke() <DispId(2)> Function GetSomeString() As String End Interface <ClassInterface(ClassInterfaceType.None), _ ProgId("CommsClass.ClientInterface"), _ Guid("1B6D1711-FD8A-4b34-A806-06B5EE45962E")> _ Public Class ClientInterface Implements _ClientInterface Public Function GetSomeString() As String Implements _ClientInterface.GetSomeString Return "Hello World From .NET" End Function Public Sub Invoke() Implements _ClientInterface.Invoke MessageBox.Show("Message Box Invoked in .NET", ".NET Message Box", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class Show quoteHide quote "SiJP" wrote: > I've been having a few issues recently in creating a vb.net class > library (using vs.net 2003), registering it for com interop and then > invoking its functions from an object in VB6. > > The error I am receiving is happening in VB6 when I go to compile the > project: > > Compile Error: > Function or Interface marked as restricted, or the function uses an > Automation type not supported in Visual Basic > > > Here is my vb6 code, which is run from a button on a test form: > > Private Sub cmdInvoke_Click() > On Error GoTo err_handler > > Dim obj As CommsClass.ClientInterface > Set obj = New CommsClass.ClientInterface > > obj.Invoke > > Exit Sub > > err_handler: > MsgBox Err & " - " & Error > > End Sub > > > And here is my vb.net CommsClass code. This is the ONLY code I have in > the project, and the project is registered for COM Interop. > > Public Class ClientInterface > Public Function Invoke() As String > MsgBox("Hi") > End Function > End Class > > Why would somthing so simply cause such an awkward error?! > > Thanks > > Thanks rmacias, I have a play with this tomorrow.
I only went the route I did (without the COM exposure) becuase I have sucessfully done this in the past and used late binding within my vb6 application to access the functions on the .net dll. .... to be continued :)
Why does Replace return Nothing???
Should I use XML as a database for a standalone app? Mail attachment from memory & char in XML document Send email best use of vb.net and multithreading "Cross-thread operation not valid" without threading!! ComboBox in Bound DataGrid (VB 2003) Deleting INI file entry Why can't I get the right control height? |
|||||||||||||||||||||||