473,387 Members | 1,516 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,387 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 7255
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.