473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

vb.net Automation Issues - COM Interop

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

Apr 13 '06 #1
2 2393
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.InterfaceIsIDispat ch), _
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

"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

Apr 13 '06 #2
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 :)

Apr 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jabailo | last post by:
I came across this article while researching a VB6 430 error: INFO: Considerations for Server-Side Automation of Office http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757 ...
1
by: cybertof | last post by:
Hello, Is there a way to connect (through automation) a c# application to a running Excel 2003 instance on a specific workbook ? In the past, i used to use GetObject(...) function in VB6. ...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
0
by: Marcus | last post by:
Hello, I have windows forms application that I build in VB.Net that uses Statistica (a statistics program) via an interop wrapper. As a stand alone app it works fine. Now my supervisor would...
2
by: leodippolito | last post by:
Sirs, I have an ASP.NET application with hundreds of users accessing it. One of its features is to merge a set of Word documents that are stored in a server (basically is copy contents from doc1...
2
by: William LaMartin | last post by:
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability,...
0
by: SiJP | last post by:
(sorry about any cross-posting on groups here... not intended) 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...
1
by: =?Utf-8?B?cm9i?= | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
1
by: allbelonging | last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook Problem: I have my outlook 2003 configured with multiple mailbox on my local machine. I want to specify the mailbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.