GasDay DevelopmentTeam
2009-07-14 19:12:44 UTC
Hello,
I've been having an issue with COM Interop over the past couple of
days.
The issue is that certain computers throw an Automation error
(-2146232576 (80131700)) when the VB6 code attempts to instantiate a
new object from the .NET code; however, the 3 development machines can
run the code without any issues.
Here are some details on what we have done thus far as well as the
configuration of the interop:
* The VB6 code is within an Excel module.
* The C# code has been set up for interop by providing COM visible
interfaces, specifying the class interface types, and registering it
to the registry by running 'regasm TestVBDLL.dll /tlb:TestVBDLL.tlb /
codebase' (after ensuring that it has been unregistered) and verifying
it is in the registry.
* After that step, the DLL/TLB is visible and usable on the
development machines AND is visible in the object browser on the
problematic machines.
* However, where we are having the issue is that once the code is
run on the problem machine it throws an automation error on the line
in which the test object is set to a new object. After that the class
is no longer visible in the object browser, but this may be unrelated.
* We've tried creating an entirely new Excel project and C# DLL
with just the bare minimum required to do the COM interop (as opposed
to the thousands of lines in the other projects) and it still fails in
the same manner.
The computers that it isn't working on are fairly new machines with
intel Core 2 Duo E6600s, 3.25GB RAM, Windows XP SP3, .NET Framework 2,
3, and 3.5, as well as Visual Basic Enterprise edition.
We've tried just about everything we can think of with regasm,
registering and unregistering, recompiling, etc.
Any help or suggestions would be greatly appreciated!
Thank you,
- Christopher Patrick
Here is the minimal code we tried to use:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TestVBDLL {
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
ComVisible(true)]
public interface IClass1 {
void doStuff();
}
[ClassInterface(ClassInterfaceType.None),
ComVisible(true)]
public class Class1 : IClass1 {
String test = String.Empty;
public Class1() {
test = "This is the variable test.";
}
public void doStuff() {
MessageBox.Show("This is a test.\n\n" + test, "A message
from .NET", MessageBoxButtons.OK);
}
}
}
//VB6
Option Explicit
Sub test()
Dim obj As Class1
Set obj = New Class1
Call obj.doStuff
End Sub
I've been having an issue with COM Interop over the past couple of
days.
The issue is that certain computers throw an Automation error
(-2146232576 (80131700)) when the VB6 code attempts to instantiate a
new object from the .NET code; however, the 3 development machines can
run the code without any issues.
Here are some details on what we have done thus far as well as the
configuration of the interop:
* The VB6 code is within an Excel module.
* The C# code has been set up for interop by providing COM visible
interfaces, specifying the class interface types, and registering it
to the registry by running 'regasm TestVBDLL.dll /tlb:TestVBDLL.tlb /
codebase' (after ensuring that it has been unregistered) and verifying
it is in the registry.
* After that step, the DLL/TLB is visible and usable on the
development machines AND is visible in the object browser on the
problematic machines.
* However, where we are having the issue is that once the code is
run on the problem machine it throws an automation error on the line
in which the test object is set to a new object. After that the class
is no longer visible in the object browser, but this may be unrelated.
* We've tried creating an entirely new Excel project and C# DLL
with just the bare minimum required to do the COM interop (as opposed
to the thousands of lines in the other projects) and it still fails in
the same manner.
The computers that it isn't working on are fairly new machines with
intel Core 2 Duo E6600s, 3.25GB RAM, Windows XP SP3, .NET Framework 2,
3, and 3.5, as well as Visual Basic Enterprise edition.
We've tried just about everything we can think of with regasm,
registering and unregistering, recompiling, etc.
Any help or suggestions would be greatly appreciated!
Thank you,
- Christopher Patrick
Here is the minimal code we tried to use:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TestVBDLL {
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
ComVisible(true)]
public interface IClass1 {
void doStuff();
}
[ClassInterface(ClassInterfaceType.None),
ComVisible(true)]
public class Class1 : IClass1 {
String test = String.Empty;
public Class1() {
test = "This is the variable test.";
}
public void doStuff() {
MessageBox.Show("This is a test.\n\n" + test, "A message
from .NET", MessageBoxButtons.OK);
}
}
}
//VB6
Option Explicit
Sub test()
Dim obj As Class1
Set obj = New Class1
Call obj.doStuff
End Sub