473,473 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ActiveX and C# Interop

I am having problems getting an ActiveX DLL written in VB6 to call a
method in a C# class library component.

My C# DLL is called CSharpProject.dll and contains a public class
called CSharpClass. In this class is a single public method that
returns the string "Hello

from C sharp".

My VB6 ActiveX DLL references the C# DLL (CSharpProject.dll) using the
type library CSharpProject.tlb. The ActiveX DLL contains two methods,
the first just

returns a string declared within the method, and the second tries to
call the method defined in the C# component.

I then have a simple ASP.Net webform (Webform1.aspx) that creates an
instance of the ActiveX object using client side Javascript.

Everything works fine on my local machine but when I try using it on
another machine I get the following error(s):

1) "File or assembly name CSharpProject, or one of its dependancies,
was not found"


I have tried the following things to resolve the problem:

C# Component:

* I have created the tlb file for the CSharpProject.dll

1) automatically using the setting in Visual Studio "Register for COM
Interop" set to true.
2) using the .net tool tlbexp
3) using regasm /tlb option

(I have also ensured that the .tlb file is registered on other
machines using a tool called Reggie.exe.)

* I have tried creating a strong name for the component and
registering it in the GAC but this doesn't solve the problem.


VB6 ActiveX DLL:

* I have referenced the tlb as per a normal reference.

The code is as follows:

Public Function method1() As String
On Error GoTo fail
foo = "dave"
Exit Function
fail:
foo = "Error in foo occurred in VB ActiveX DLL (" & Err.Description
& ")"
End Function

Public Function method2() As String
On Error GoTo fail
Dim objCSharp As New CSharpProject.CSharpClass
Dim tmp As String
tmp = objCSharp.foo()
method2 = tmp
Exit Function
fail:
method2 = "Error occurred in VB ActiveX DLL (" & Err.Description &
")"
End Function

NOte: I have also tried using the following code to declare and
instantiate the C# class -

Dim objCSharp
Set objCSharp = CreateObject("CSharpProject.CSharpClass")

However this returns the following error message from the VB6 ActiveX
DLL: "Object doesn't support this property or method."


javascript:

var obj = new ActiveXObject("VBActiveXDLL.VBClass1");
alert(obj.method1());
alert(obj.method2());

All works fine on my local machine but when I copy/register/install
all the components on another machine (which has Visual Studio.Net and
v6 installed) it

doesn't work.

Any suggestions, comments, or ideas would be much appreciated
Thanks

Craig
Jul 21 '05 #1
0 1896

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

Similar topics

0
by: Sorin | last post by:
Hi all I have a .NET application that is using few ActiveX DLL wrote in VB6. I managed to get the most from my previous VB6 controls by using them in .NET but sometimes when I am using my...
1
by: Craig | last post by:
I am having problems getting an ActiveX DLL written in VB6 to call a method in a C# class library component. My C# DLL is called CSharpProject.dll and contains a public class called CSharpClass....
5
by: andy.g.ward | last post by:
I keep getting this when trying to create an MFC activex control in a c# windows service - anyone got any ideas what the missing module could be??? Exception thrown :...
1
by: James Pannozzi | last post by:
I'm just starting a C++ application which will send data to someone else's program (written as a VB ActiveX COM app) and receive some data back from it. I have the Visual Studio .NET 2003...
1
by: Mehr H | last post by:
I have been working on this for several days and am still have had no success in achieving this. Pleae help. It seems that documentation for this is very limited. I have looked in several books and...
4
by: FanTian | last post by:
I want to insert an ActiveX control into asp .net web page, but it seems I fall in trouble now. When I insert the ocx control into toolbox and drag it to the web page, I can't get its ID. and if I...
3
by: Jeffery Franzen | last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms? I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app. I do the add...
23
by: Galen Somerville | last post by:
A VB6 ActiveX.exe raises an event which is seen by the VB6 App. Same setup in VB2005. The event to be raised is in form frmSweep. As in VB6, frmSweep is hidden when the events take place. I...
3
by: Lou | last post by:
I know I can make an ActiveX dll in .NET and it uses interop. So I end up with 2 files, the .dll and the interop file. I also know I need to use Regasm or something like that to register the .dll...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.