Unable to create .NET class in VBA  
Author Message
Tarp





PostPosted: Visual Basic for Applications (VBA), Unable to create .NET class in VBA Top

I'm trying to use a .NET DLL from VBA, but i keep getting a error message in VBA:
"Run-time error '-2147024894 (80070002)':
"File or assambly name ClassLibrary1, or one of its dependincies, was not found."

I'm running VS 2005 and I have selected "Register for COM interop" and "Make assembly COM visible" in the properties window for the project.

The code is rather simple C#:

namespace ClassLibrary1 {

public interface IClass1 {bool getTrue();}

[ClassInterface(ClassInterfaceType.AutoDual)]

public class Class1 :IClass1 {

public Class1 (){ }

public bool getTrue() {return true ;}

}

}
And the VBA code is also rather simple:
Public Sub test()
    Dim d As ClassLibrary1.Class1
    Set d = New ClassLibrary1.Class1
End Sub
and it always fails in line 2.
I can browse my way to the namespace and the class.

Can anyone help please
I'm getting desperate !!!!




Microsoft ISV Community Center Forums2  
 
 
Tarp





PostPosted: Visual Basic for Applications (VBA), Unable to create .NET class in VBA Top

The problem was not in my code but there is/was a error in the 2.0 framework.
A fix was released 2005-12-02 and it works:
http://support.microsoft.com/default.aspx/kb/908002


 
 
KrisFB_APPS





PostPosted: Visual Basic for Applications (VBA), Unable to create .NET class in VBA Top

Tarp,

While we are not exactly talking the same type of DLL (or COM) your answers helped me after three days of searching! I had an app that needed to be invoked from Excel 2000 VBA code. My problem was: I could invoke NET Framework 1.1 DLLs but not the NET Framework 2.0 DLLs. As you stated, something went wrong when they created Framework 2. I could not even do this using Excel 2003. Since we upgraded to Visual Studio 2005, I had to get this call from Excel working or it was back to redesigning a major part of our application. It also deals with customer credit card numbers, therefore I could not have cut the usual corners I wanted to.

Thank you for posting the question as well as the reply. I hope you see this, since you posted it last year Dec.

Kris