Custom .NET COM DLL Works on XP Pro But Not on Server 2008

Trips

Well-known member
Joined
Aug 7, 2010
Messages
2,788
I developed a customer COM DLL using C#.Net that I need to call from VBA inside an MS Access application. Inside the code for the MS Access .mdb, I was a able to create a reference to the DLL by browsing for the .tlb file that is created along with the .dll.
After this, I created the object and called the method and it worked fine. Next, I moved the .dll and .tlb files to a Server 2008 R2 machine along with the .mdb. When my code runs, I get a Run-time error 429: ActiveX component cant create object
on the Set myTest = New TestDLL.Test.
I am testing as full administrator. I have verified the path to the dll. What would be the difference between the two machines?
Test.cs
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.Runtime.InteropServices;

<span style="color:Blue; namespace TestDLL
{
<span style="color:Blue; public <span style="color:Blue; class Test
{
<span style="color:Blue; public String HelloWorld()
{
<span style="color:Blue; return <span style="color:#A31515; "Hello World";
}

}
}
[/code]
AssemblyInfo.cs
<div style="color:Black;background-color:White; <pre>
<span style="color:Green; // Setting ComVisible to false makes the types in this assembly not visible
<span style="color:Green; // to COM components. If you need to access a type in this assembly from
<span style="color:Green; // COM, set the ComVisible attribute to true on that type.
[<span style="color:Blue; assembly: ComVisible(true)]
<span style="color:Green; // The following GUID is for the ID of the typelib if this project is exposed to COM
[<span style="color:Blue; assembly: Guid(<span style="color:#A31515; "0741e023-2964-439e-964b-683e7624f7cb")]

<span style="color:Green; // Version information for an assembly consists of the following four values:
<span style="color:Green; //
<span style="color:Green; // Major Version
<span style="color:Green; // Minor Version
<span style="color:Green; // Build Number
<span style="color:Green; // Revision
<span style="color:Green; //
<span style="color:Green; // You can specify all the values or you can default the Revision and Build Numbers
<span style="color:Green; // by using the * as shown below:
[<span style="color:Blue; assembly: AssemblyVersion(<span style="color:#A31515; "1.0.0.0")]
[<span style="color:Blue; assembly: AssemblyFileVersion(<span style="color:#A31515; "1.0.0.0")]
[<span style="color:Blue; assembly: AllowPartiallyTrustedCallers]

[/code]
VBA
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Public <span style="color:Blue; Sub test2()
<span style="color:Blue; Dim myTestDLL <span style="color:Blue; As TestDLL.test
<span style="color:Blue; Set myTestDLL = <span style="color:Blue; New TestDLL.test

MsgBox myTestDLL.HelloWorld()
<span style="color:Blue; End <span style="color:Blue; Sub

[/code]
Thank you,
Steve

View the full article
 
Back
Top