473,418 Members | 2,072 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,418 software developers and data experts.

VB6 automation error trying to use a COM-exposed C# DLL

Hi,

I have two PCs:
PC1: Visual Studio 2005 (including .NET framework 2.0.
PC2: Visual Studio 6 (using Visual Basic 6) + .NET framework 2.0 installed separately.

On PC1 I wrote and built a C# DLL (see code below), and created one .tlb and one .reg file to expose
its methods to COM.

On PC2 I copied the .dll, .tlb and .reg into WINDOWS\system32, and executed the .reg to insert new
entries to the registry. In Visual Basic 6, I created a new project, and added a reference to the
..tlb. So far, everything seems to be ok. I can see the class in the object inspector, and browse its
methods and enumerations. Also, the tool that shows as I type the valid methods and parameters works
ok. Compilation to exe works fine. Problems start at run time. Just trying to instantiate one
instance of the COM exposed class gives me a "Run-time error '-2147024894 (80070002) Automation
error'". See VB6 code below, too. Both listings have dummy code.

Any hint about what can this be due to?

Thank you,
Tremendo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%

using System;
using System.Text;
using System.Runtime.InteropServices;

namespace N_Proc_CC1100_Test
{
public enum RadiobandTypes
{
RadiobandR =0,
RadiobandRC,
RadiobandRCS,
RadiobandT
}
// ================================================== =======================
[GuidAttribute("AEB5062F-6695-4484-B07A-53C37A99E92B")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)]
public interface _C_Proc_CC1100_Test
{
[DispIdAttribute(1)]
bool EnterTestMode(int RadiobandType);

[DispIdAttribute(2)]
bool LeaveTestMode();

[DispIdAttribute(3)]
bool GetSoftwareVersion(out int version);

[DispIdAttribute(4)]
bool TestRF(out double PeakFrequency_MHz,out double PeakPower_dBm);

[DispIdAttribute(5)]
bool SetOutputs(int outputs);

[DispIdAttribute(6)]
bool GetInputs(out int inputs);
}
// ================================================== =======================
[GuidAttribute("A9BA5B44-A432-44ab-9AFA-6C8058B20AA8")]
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ProgIdAttribute("N_Test.C_Test")]
public class C_Proc_CC1100_Test : _C_Proc_CC1100_Test
{
public RadiobandTypes RadiobandType;
public bool InTestMode;
// .................................................. ...................
public C_Proc_CC1100_Test()
{
RadiobandType =RadiobandTypes.RadiobandR;
InTestMode =false;
}
// .................................................. ...................
public bool EnterTestMode(int RadiobandType)
{
this.RadiobandType =(RadiobandTypes)RadiobandType;

InTestMode =true;
return(true);
}
// .................................................. ...................
public bool LeaveTestMode()
{
InTestMode =false;
return(true);
}
// .................................................. ...................
public bool GetSoftwareVersion(out int version)
{
version =(int)0x1234;
return(true);
}
// .................................................. ...................
public bool TestRF(out double PeakFrequency_MHz,out double PeakPower_dBm)
{
PeakFrequency_MHz =868.9;
PeakPower_dBm =-65.0;
return(true);
}
// .................................................. ...................
public bool SetOutputs(int outputs)
{
return(true);
}
// .................................................. ...................
public bool GetInputs(out int inputs)
{
inputs =(int)0x5678;
return(true);
}
// .................................................. ...................
} // C_Proc_CC1100_Test
// ================================================== =======================
} // N_Proc_CC1100_Test

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%

Private Sub Command1_Click()

Dim oXXX As C_Proc_CC1100_Test
Set oXXX = New C_Proc_CC1100_Test

End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%

Feb 7 '07 #1
5 11713
"Tremendo" <no****@hatespam.comwrote in message
news:04********************************@4ax.com...
Hi,

I have two PCs:
PC1: Visual Studio 2005 (including .NET framework 2.0.
PC2: Visual Studio 6 (using Visual Basic 6) + .NET framework 2.0 installed separately.

On PC1 I wrote and built a C# DLL (see code below), and created one .tlb and one .reg file
to expose
its methods to COM.

On PC2 I copied the .dll, .tlb and .reg into WINDOWS\system32, and executed the .reg to
insert new
entries to the registry. In Visual Basic 6, I created a new project, and added a reference
to the
.tlb. So far, everything seems to be ok. I can see the class in the object inspector, and
browse its
methods and enumerations. Also, the tool that shows as I type the valid methods and
parameters works
ok. Compilation to exe works fine. Problems start at run time. Just trying to instantiate
one
instance of the COM exposed class gives me a "Run-time error '-2147024894 (80070002)
Automation
error'". See VB6 code below, too. Both listings have dummy code.

Any hint about what can this be due to?

Thank you,
Tremendo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%

using System;
using System.Text;
using System.Runtime.InteropServices;

namespace N_Proc_CC1100_Test
{
public enum RadiobandTypes
{
RadiobandR =0,
RadiobandRC,
RadiobandRCS,
RadiobandT
}
// ================================================== =======================
[GuidAttribute("AEB5062F-6695-4484-B07A-53C37A99E92B")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)]
public interface _C_Proc_CC1100_Test
{
[DispIdAttribute(1)]
bool EnterTestMode(int RadiobandType);

[DispIdAttribute(2)]
bool LeaveTestMode();

[DispIdAttribute(3)]
bool GetSoftwareVersion(out int version);

[DispIdAttribute(4)]
bool TestRF(out double PeakFrequency_MHz,out double PeakPower_dBm);

[DispIdAttribute(5)]
bool SetOutputs(int outputs);

[DispIdAttribute(6)]
bool GetInputs(out int inputs);
}
// ================================================== =======================
[GuidAttribute("A9BA5B44-A432-44ab-9AFA-6C8058B20AA8")]
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ProgIdAttribute("N_Test.C_Test")]
public class C_Proc_CC1100_Test : _C_Proc_CC1100_Test
{
public RadiobandTypes RadiobandType;
public bool InTestMode;
// .................................................. ...................
public C_Proc_CC1100_Test()
{
RadiobandType =RadiobandTypes.RadiobandR;
InTestMode =false;
}
// .................................................. ...................
public bool EnterTestMode(int RadiobandType)
{
this.RadiobandType =(RadiobandTypes)RadiobandType;

InTestMode =true;
return(true);
}
// .................................................. ...................
public bool LeaveTestMode()
{
InTestMode =false;
return(true);
}
// .................................................. ...................
public bool GetSoftwareVersion(out int version)
{
version =(int)0x1234;
return(true);
}
// .................................................. ...................
public bool TestRF(out double PeakFrequency_MHz,out double PeakPower_dBm)
{
PeakFrequency_MHz =868.9;
PeakPower_dBm =-65.0;
return(true);
}
// .................................................. ...................
public bool SetOutputs(int outputs)
{
return(true);
}
// .................................................. ...................
public bool GetInputs(out int inputs)
{
inputs =(int)0x5678;
return(true);
}
// .................................................. ...................
} // C_Proc_CC1100_Test
// ================================================== =======================
} // N_Proc_CC1100_Test

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%

Private Sub Command1_Click()

Dim oXXX As C_Proc_CC1100_Test
Set oXXX = New C_Proc_CC1100_Test

End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%


You need to regasm the dll on the target system. You should also not install this in a
private folder not in a system folder like System32, use the "/codebase " option when
running regasm or register the dll in the GAC if you need this server to be accessible from
multiple clients.

Willy.

Feb 7 '07 #2
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:eM**************@TK2MSFTNGP03.phx.gbl...
"Tremendo" <no****@hatespam.comwrote in message
news:04********************************@4ax.com...
>error'". See VB6 code below, too. Both listings have dummy code.
Any hint about what can this be due to?
You need to regasm the dll on the target system. You should also not install this in a
private folder not in a system folder like System32, use the "/codebase " option when
running regasm or register the dll in the GAC if you need this server to be accessible
from multiple clients.

Willy.

Oh, and make sure you don't need other dependencies on the target machine. Or - the joy of
posting dummy code.

Willy.

Feb 7 '07 #3
"Tremendo" <no****@hatespam.comschrieb
Hi,

I have two PCs:
PC1: Visual Studio 2005 (including .NET framework 2.0.
PC2: Visual Studio 6 (using Visual Basic 6) + .NET framework 2.0
installed separately.

On PC1 I wrote and built a C# DLL (see code below), and created one
.tlb and one .reg file to expose its methods to COM.

On PC2 I copied the .dll, .tlb and .reg into WINDOWS\system32, and
executed the .reg to insert new entries to the registry. In Visual
Basic 6, I created a new project, and added a reference to the .tlb.
So far, everything seems to be ok. I can see the class in the object
inspector, and browse its methods and enumerations. Also, the tool
that shows as I type the valid methods and parameters works ok.
Compilation to exe works fine. Problems start at run time. Just
trying to instantiate one instance of the COM exposed class gives me
a "Run-time error '-2147024894 (80070002) Automation error'". See
VB6 code below, too. Both listings have dummy code.

Any hint about what can this be due to?
I don't know whether the .reg file is a replacement, but I usually only
deploy the DLL, then use regasm.exe /tlb to register the files on the client
machine and to have the tlb file created.

Armin
PS: I don't see the relation to VB.Net.

Feb 7 '07 #4
On Wed, 7 Feb 2007 11:42:25 +0100, "Willy Denoyette [MVP]" <wi*************@telenet.bewrote:
>You need to regasm the dll on the target system. You should also not install this in a
I guess you meant "You should also install", right? I assumed that, and installed the dll in a
private folder, as you can read in my other post.
>private folder not in a system folder like System32, use the "/codebase " option when
running regasm or register the dll in the GAC if you need this server to be accessible from
multiple clients.
Ok, this seems to work. I run "regasm Prod_CC1100_Test.dll /codebase /tlb", and it works for me. It
seems to need the "/codebase" option.

I didn't need to do anything with the GAC. Only one client will need to access that COM object (is
that the name?).

Thank you very much!

Feb 8 '07 #5
"Tremendo" <no****@hatespam.comwrote in message
news:p3********************************@4ax.com...
On Wed, 7 Feb 2007 11:42:25 +0100, "Willy Denoyette [MVP]" <wi*************@telenet.be>
wrote:
>>You need to regasm the dll on the target system. You should also not install this in a

I guess you meant "You should also install", right? I assumed that, and installed the dll
in a
private folder, as you can read in my other post.
Yep, that's what I meant.
>>private folder not in a system folder like System32, use the "/codebase " option when
running regasm or register the dll in the GAC if you need this server to be accessible
from
multiple clients.

Ok, this seems to work. I run "regasm Prod_CC1100_Test.dll /codebase /tlb", and it works
for me. It
seems to need the "/codebase" option.
The codebase option is all you need, just make sure you got your assembly signed.
I didn't need to do anything with the GAC. Only one client will need to access that COM
object (is
that the name?).
Multiple native COM clients can acces that COM server without the need to install it in the
GAC. The GAC is only required if you have multiple managed clients (or a mix of
native/managed) accessing the assembly.

Willy.

Feb 8 '07 #6

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 ...
17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
25
by: Neil Ginsberg | last post by:
I have a strange situation with my Access 2000 database. I have code in the database which has worked fine for years, and now all of a sudden doesn't work fine on one or two of my client's...
21
by: Neil | last post by:
Is there a way to trap an error generated in another app that is controlled via automation? I have an Access 2000 app that opens Word 2000 and proceeds to open a series of documents and, in each...
1
by: Ueslei R. Valentini | last post by:
Hi! Does anyone figured out this error when trying to create a new page in a web project under Windows2003, using Visual Studio .Net 2003? "Automation server can't create object " HSH Ueslei
3
by: Alejandro Penate-Diaz | last post by:
Hi. While trying to create a a word document in one of my asp.net pages I keep getting an ASP.NET permission error. first I thought it was been caused while trying to save the document, and I added...
12
by: elziko | last post by:
I'm using late binding (I must) to automate Excel. My code opens Excel after createing and poulating some sheets. My problem is that when the user finally decides to close Excel its process is...
8
by: Steven Scaife | last post by:
Hello I am creating a reporting system using SQL Server 2000 and ASP, I have created 4 pages that display the results i want, however the reports take an average of 20 mins to run and i have...
1
by: Bruce | last post by:
Hello, I know this must be something simple I'm overlooking but I can't get err.raise inside a class to return anything but 440 - automation error. For example, if I create the following test...
1
by: acog1 | last post by:
Hi everyone, I know that there is a question similar to this already posted but the answer to it does not really seem to relate to my problem! So here goes... I have a main form which has a tab...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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,...

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.