Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Calling a C# dll with VBA
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Gary Clifford
08-21-04 09:02 AM


Re: Calling a C# dll with VBA
I 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Samuel Hon
08-24-04 02:07 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:44 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.