T
Tremendo
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.InterfaceIsIDispatch)]
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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.InterfaceIsIDispatch)]
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%