Home All Groups Group Topic Archive Search About

How Do I Create an Entry Point for a DLL?

Author
29 Jul 2006 4:45 AM
TC
I'm using VB.NET 2005. I need to create a DLL containing a function
F(). A VB.NET application will reference the DLL by using a Declare
statement.

    Declare Function F Lib "Foo.dll" (ByVal Woo As String) As Double

When I write the DLL and test it, however, I get a runtime error.

    Unable to find an entry point named 'F' in DLL 'Foo.dll'.

Judging from the error, it sounds like I need to create an "entry
point" in my DLL. Can anyone tell me how to do that?

Please note that I have no control over the code which calls my
function. That code uses a Declare statement.


-TC

Author
29 Jul 2006 8:21 AM
Tom Shelton
TC wrote:
> I'm using VB.NET 2005. I need to create a DLL containing a function
> F(). A VB.NET application will reference the DLL by using a Declare
> statement.
>
>     Declare Function F Lib "Foo.dll" (ByVal Woo As String) As Double
>
> When I write the DLL and test it, however, I get a runtime error.
>
>     Unable to find an entry point named 'F' in DLL 'Foo.dll'.
>
> Judging from the error, it sounds like I need to create an "entry
> point" in my DLL. Can anyone tell me how to do that?
>

You can't.  Declare statements are used to interact with native dll's
not managed dll's, in other words, managed applications do not
reference managed dll's via a declare statement.  You will need to
write your dll in a language that supports this - like C++, PowerBasic,
etc.

Of course, there may be hacks to do this, just as there were for
VB.CLASSIC.  I haven't looked, nor would I ever suggest anyone did
this.  It is just not the way the tool your using works.

--
Tom Shelton
Author
30 Jul 2006 12:14 PM
Michel Posseth [MCP]
Hacks , for Vb classic ???

http://www.windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html

i do not see somuch hack about it ,, i see it more as a undocumented feature
:-)

Haven`t tried it but it might also work in VB.Net


regards

Michel Posseth



Show quoteHide quote
"Tom Shelton" <t**@mtogden.com> schreef in bericht
news:1154161265.375548.86670@h48g2000cwc.googlegroups.com...
>
> TC wrote:
>> I'm using VB.NET 2005. I need to create a DLL containing a function
>> F(). A VB.NET application will reference the DLL by using a Declare
>> statement.
>>
>>     Declare Function F Lib "Foo.dll" (ByVal Woo As String) As Double
>>
>> When I write the DLL and test it, however, I get a runtime error.
>>
>>     Unable to find an entry point named 'F' in DLL 'Foo.dll'.
>>
>> Judging from the error, it sounds like I need to create an "entry
>> point" in my DLL. Can anyone tell me how to do that?
>>
>
> You can't.  Declare statements are used to interact with native dll's
> not managed dll's, in other words, managed applications do not
> reference managed dll's via a declare statement.  You will need to
> write your dll in a language that supports this - like C++, PowerBasic,
> etc.
>
> Of course, there may be hacks to do this, just as there were for
> VB.CLASSIC.  I haven't looked, nor would I ever suggest anyone did
> this.  It is just not the way the tool your using works.
>
> --
> Tom Shelton
>
Author
31 Jul 2006 5:12 AM
Michel Posseth [MCP]
Have just tried it and No i can`t get it to run ,, so it doesn`t work ,,,,
or i am missing something


Show quoteHide quote
"Michel Posseth [MCP]" <M***@posseth.com> schreef in bericht
news:egJNKG9sGHA.4140@TK2MSFTNGP06.phx.gbl...
>
> Hacks , for Vb classic ???
>
> http://www.windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html
>
> i do not see somuch hack about it ,, i see it more as a undocumented
> feature :-)
>
> Haven`t tried it but it might also work in VB.Net
>
>
> regards
>
> Michel Posseth
>
>
>
> "Tom Shelton" <t**@mtogden.com> schreef in bericht
> news:1154161265.375548.86670@h48g2000cwc.googlegroups.com...
>>
>> TC wrote:
>>> I'm using VB.NET 2005. I need to create a DLL containing a function
>>> F(). A VB.NET application will reference the DLL by using a Declare
>>> statement.
>>>
>>>     Declare Function F Lib "Foo.dll" (ByVal Woo As String) As Double
>>>
>>> When I write the DLL and test it, however, I get a runtime error.
>>>
>>>     Unable to find an entry point named 'F' in DLL 'Foo.dll'.
>>>
>>> Judging from the error, it sounds like I need to create an "entry
>>> point" in my DLL. Can anyone tell me how to do that?
>>>
>>
>> You can't.  Declare statements are used to interact with native dll's
>> not managed dll's, in other words, managed applications do not
>> reference managed dll's via a declare statement.  You will need to
>> write your dll in a language that supports this - like C++, PowerBasic,
>> etc.
>>
>> Of course, there may be hacks to do this, just as there were for
>> VB.CLASSIC.  I haven't looked, nor would I ever suggest anyone did
>> this.  It is just not the way the tool your using works.
>>
>> --
>> Tom Shelton
>>
>
>
Author
30 Jul 2006 6:10 PM
TC
Tom,

Thank you for the clear answer. I wrote the code in C++ and it works
well.

How can I know which languages support native DLLs and which support
managed DLLs? I used the Borland C++ compiler to generate my DLLs.
Could I have used Visual C++ .NET instead?

-TC


Tom Shelton wrote:
Show quoteHide quote
> TC wrote:
> > I'm using VB.NET 2005. I need to create a DLL containing a function
> > F(). A VB.NET application will reference the DLL by using a Declare
> > statement.
> >
> >     Declare Function F Lib "Foo.dll" (ByVal Woo As String) As Double
> >
> > When I write the DLL and test it, however, I get a runtime error.
> >
> >     Unable to find an entry point named 'F' in DLL 'Foo.dll'.
> >
> > Judging from the error, it sounds like I need to create an "entry
> > point" in my DLL. Can anyone tell me how to do that?
> >
>
> You can't.  Declare statements are used to interact with native dll's
> not managed dll's, in other words, managed applications do not
> reference managed dll's via a declare statement.  You will need to
> write your dll in a language that supports this - like C++, PowerBasic,
> etc.
>
> Of course, there may be hacks to do this, just as there were for
> VB.CLASSIC.  I haven't looked, nor would I ever suggest anyone did
> this.  It is just not the way the tool your using works.
>
> --
> Tom Shelton
Author
30 Jul 2006 6:25 PM
Herfried K. Wagner [MVP]
"TC" <golemdan***@yahoo.com> schrieb:
> How can I know which languages support native DLLs and which support
> managed DLLs? I used the Borland C++ compiler to generate my DLLs.
> Could I have used Visual C++ .NET instead?

Yes, you could have used Visual C++ .NET to do that.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>