Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, can anyone help please.
I am trying to create a DLL in C# and then call it from Excel VBA. I
have plenty of experience with VBA but none with C#. I get the error
message "Can't find DLL entry point myFirstDll in testdll".
The code for this trivial example is in file testdll.cs as follows:
Class testdll {
Public static int myFirstDll () {
Return 5;
}
}
I compiled it using the command line as follows:
csc /t:library /out:testdll.dll testdll.cs
and called it with:
Declare Function myFirstDll Lib "testdll.dll" () as integer
Sub CallTestDll()
Msgbox myFirstDll()
End sub
Can anyone give me a pointer as to how I can get this to work.
Thanks.
Post Follow-up to this messageI think the problem is the compilation.
There is a setting in Visual Studio "register for com interop" under
Project Properties / Build
I dont think .NET dll's are COM compliant without this flag
Sam
gary@cityfusion.co.uk (Gary Clifford) wrote in message news:<6e0ec798.0408200200.20a23d62@p
osting.google.com>...
> Hi, can anyone help please.
>
> I am trying to create a DLL in C# and then call it from Excel VBA. I
> have plenty of experience with VBA but none with C#. I get the error
> message "Can't find DLL entry point myFirstDll in testdll".
>
> The code for this trivial example is in file testdll.cs as follows:
>
> Class testdll {
> Public static int myFirstDll () {
> Return 5;
> }
> }
>
> I compiled it using the command line as follows:
>
> csc /t:library /out:testdll.dll testdll.cs
>
> and called it with:
>
> Declare Function myFirstDll Lib "testdll.dll" () as integer
>
> Sub CallTestDll()
> Msgbox myFirstDll()
> End sub
>
> Can anyone give me a pointer as to how I can get this to work.
> Thanks.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.