472,371 Members | 1,596 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

C# - Com Interop - ClassInterfaceType.None

HL
I want to use the services of a C# dll from a VB6 client. The C# dll has a
public method called "Add". In the C# dll, the class interface type applied
for the class is as follows:

[ClassInterface(ClassInterfaceType.None)]

The Com visible attribute for the type is set to true.
[ComVisible(true)]

I used RegAsm Utility to generate the Tlb file.

In the VB6 client, I set a reference to the tlb file. I create an instance
of the type as follows:

Dim Ret As Integer
Dim oSample As New Sample

The problem is that the intellisense does not show the Add method at all. It
only shows - Equals, GetHashCode, GetType and ToString.

Where am I going wrong?
Nov 25 '05 #1
9 7148
It seems that your class does not implement any interface and regasm
exposes _Object as the default interface. To have Add shown with
intellisense, you need to declare an interface containing Add method,
and let your class extend it.

Thi
http://thith.blogspot.com

Nov 25 '05 #2
HL
Hi,

Thank you for the quick response.

As per your suggestion, I have now implemented an interface with the Method
Add.

In VB6, the Intellisense shows the method "Add" only (as I wanted).

But, the problem now is that the following statement gives an Automation
error.

oSample.Add();

The same method call works fine, when I call the Add method from a C# Test
Exe.

"Truong Hong Thi" wrote:
It seems that your class does not implement any interface and regasm
exposes _Object as the default interface. To have Add shown with
intellisense, you need to declare an interface containing Add method,
and let your class extend it.

Thi
http://thith.blogspot.com

Nov 25 '05 #3
HL

I tried the following method and still the same error.

An automation is thrown, when the C# Dll is created in the following manner.

Dim oSample as Sample
set oSample = new Sample()

The Automation error says "The System cannot find the file specified"
Run-time error - '2147024894(80070002).

Please Help.
"Truong Hong Thi" wrote:
It seems that your class does not implement any interface and regasm
exposes _Object as the default interface. To have Add shown with
intellisense, you need to declare an interface containing Add method,
and let your class extend it.

Thi
http://thith.blogspot.com

Nov 25 '05 #4
Hi, could you post more info:
What did the error say?
How complex is your add method?
And some more info if you think it is useful.

Thi

Nov 25 '05 #5
HL
Hi,

The Add method is just a test method and there is just a
Console.Writeline statement and nothing more.

Looks like the VB6 client is not able to locate the C# dll , because the
creation of the object itself is throwing an error. Am I missing something
else?

"Truong Hong Thi" wrote:
Hi, could you post more info:
What did the error say?
How complex is your add method?
And some more info if you think it is useful.

Thi

Nov 25 '05 #6
It complains that the DLL you compiled with C# is not found.
You can do one of the following:
- copy the DLL to VB installation folder (likely C:\Program
Files\Microsoft Visual Studio\VB98)
- copy DLL to OS system folder (e.g WinNT/System32)
- Copy the DLL file to the same folder as your VB DLL/EXE. This does
not work if you want to debug your code because you can only generate
VB DLL/EXE by File/Make XXX.... menu item.

It is annoying that VB6 does not support "Working Directory" project
property for debugging; otherwise you can set it to the folder
containning the C# DLL.

Hope it helps,
Thi - http://thith.blogspot.com

Nov 25 '05 #7
HL
Thanks a lot Thi. It works fine now.

Just one Doubt.
The Vb Exe should have located the path of the C# Dll from the registry and
executed. Why is it required to place the VB Exe in the same path as the C#
Dll?

"Truong Hong Thi" wrote:
It complains that the DLL you compiled with C# is not found.
You can do one of the following:
- copy the DLL to VB installation folder (likely C:\Program
Files\Microsoft Visual Studio\VB98)
- copy DLL to OS system folder (e.g WinNT/System32)
- Copy the DLL file to the same folder as your VB DLL/EXE. This does
not work if you want to debug your code because you can only generate
VB DLL/EXE by File/Make XXX.... menu item.

It is annoying that VB6 does not support "Working Directory" project
property for debugging; otherwise you can set it to the folder
containning the C# DLL.

Hope it helps,
Thi - http://thith.blogspot.com

Nov 25 '05 #8
Use the /codebase option when running regasm.

Willy.

"HL" <HL@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
Thanks a lot Thi. It works fine now.

Just one Doubt.
The Vb Exe should have located the path of the C# Dll from the registry
and
executed. Why is it required to place the VB Exe in the same path as the
C#
Dll?

"Truong Hong Thi" wrote:
It complains that the DLL you compiled with C# is not found.
You can do one of the following:
- copy the DLL to VB installation folder (likely C:\Program
Files\Microsoft Visual Studio\VB98)
- copy DLL to OS system folder (e.g WinNT/System32)
- Copy the DLL file to the same folder as your VB DLL/EXE. This does
not work if you want to debug your code because you can only generate
VB DLL/EXE by File/Make XXX.... menu item.

It is annoying that VB6 does not support "Working Directory" project
property for debugging; otherwise you can set it to the folder
containning the C# DLL.

Hope it helps,
Thi - http://thith.blogspot.com

Nov 25 '05 #9
HL
Hi Willy,

What are the pros and cons of using the /Codebase option to make an
entry for the .NET assembly in the registry vis-a-vis placing the .NET
assembly (that is used by COM) in the GAC?

"Willy Denoyette [MVP]" wrote:
Use the /codebase option when running regasm.

Willy.

"HL" <HL@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
Thanks a lot Thi. It works fine now.

Just one Doubt.
The Vb Exe should have located the path of the C# Dll from the registry
and
executed. Why is it required to place the VB Exe in the same path as the
C#
Dll?

"Truong Hong Thi" wrote:
It complains that the DLL you compiled with C# is not found.
You can do one of the following:
- copy the DLL to VB installation folder (likely C:\Program
Files\Microsoft Visual Studio\VB98)
- copy DLL to OS system folder (e.g WinNT/System32)
- Copy the DLL file to the same folder as your VB DLL/EXE. This does
not work if you want to debug your code because you can only generate
VB DLL/EXE by File/Make XXX.... menu item.

It is annoying that VB6 does not support "Working Directory" project
property for debugging; otherwise you can set it to the folder
containning the C# DLL.

Hope it helps,
Thi - http://thith.blogspot.com


Nov 30 '05 #10

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

Similar topics

7
by: Josef | last post by:
Hello, I want to create a C# class library which I can use in an Excel VBA macro. I created a C# class library and set the "Register for COM Interop" option in Visual Studio to TRUE. Now in...
26
by: Vish | last post by:
Hi, I am trying to expose my .NET 2.0 class as a COM type using the following attributes for the attributes I have the "Register for COM Interop" build property set to true. I also have...
16
by: Asaf | last post by:
I am trying to create and use a COM object with C#.NET 2005. The assembly is set to "Register for COM interop" but when I am trying to call it from VB on Word 2003 I am getting this error: ...
1
by: intrader | last post by:
I have a .NET interop assembly Hash.MD5Sum with two methods Identity and GetMD5Sum. I want to call the methods from ASP (JScript), The debugger tells me that object oMD5Sum has one the ToString()...
2
by: intrader | last post by:
I have a .NET interop assembly Hash.MD5Sum with two methods Identity and GetMD5Sum. I want to call the methods from ASP (JScript), The debugger tells me that object oMD5Sum has only one method...
0
by: Tech quest | last post by:
Hi, I have a C# Class Libarary which is exposed to COM. The issue is base class members are not exposed to COM.As per msdn http://msdn2.microsoft.com/en-us/library/8877bdk6(VS.80).aspx Managed...
3
by: =?Utf-8?B?VGVycnk=?= | last post by:
I have made up a contrived example show the problem I am having. I have some ReadOnly interfaces: Public Interface IROPerson ReadOnly Property FirstName() As String ReadOnly Property LastName()...
0
by: DKn | last post by:
Hello All, I am having a C#.Net Windows Control Library Project.. I want to use this control in vb. for that i have done like this public partial class MyControl : UserControl...
0
by: iprogram2008 | last post by:
I have a huge complex app.config and one of the sections in the config is connection strings. I have a dot net class that uses this app.config and a com interop is generated for this dot net class....
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.