50,236 Members
2 added today
248,628 Resources
73 added today

All Devdex   All VBdex   Current Category
VBdex > Forums & Newsgroups > Newsgroups > microsoft.public.dotnet.languages.vb Add this category to My Favorites

View Message Thread  (11 replies)

Results 1 - 10 of 12 Next Page »

Help Calling A Function from a 32-bit non-.NET DLL Add this thread to My Favorites
From: Dave Wurtz
Date Posted: 6/7/2010 4:08:00 PM

In my VB.NET application, I'm trying to call a function from a 32-bit,
non-.NET dll file and I'm having problems. I believe I have the
correct signature for the dll with:

<System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
_
Public Shared Function BuildCompositeFile(ByVal szOldFile As
System.IntPtr, _
ByVal szNewFile As System.IntPtr, _
ByVal szCompositeFile As System.IntPtr, _
ByVal szOldPrefix As System.IntPtr, _
ByVal szNewPrefix As System.IntPtr, _
ByVal szCompositePrefix As System.IntPtr, _
ByVal bCheckForChangedImages As System.Boolean) As System.Int32
End Function


I'm trying to call this function with the following code:

Dim html1 As System.String = "c:\test1.htm"
Dim html2 As System.String = "c:\test2.htm"
Dim composite As System.String = "c:\changes.htm"

Dim changes As System.Int32 = GlobalApp.BuildCompositeFile( _
System.Runtime.InteropServices.Marshal.ReadIntPtr(html1, 0), _
System.Runtime.InteropServices.Marshal.ReadIntPtr(html2, 0), _
System.Runtime.InteropServices.Marshal.ReadIntPtr(composite, 0), _
System.Runtime.InteropServices.Marshal.ReadIntPtr(".htm", 0), _
System.Runtime.InteropServices.Marshal.ReadIntPtr(".htm", 0), _
System.Runtime.InteropServices.Marshal.ReadIntPtr(".htm", 0), _
True)

When I run this, I get the error:
An exception of type 'System.EntryPointNotFoundException' occurred in
ProductVision.Windows.Forms.dll but was not handled in user code.
Additional information: Unable to find an entry point named
'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.

What am I doing wrong?

Thanks in advance!
Dave

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Herfried K. Wagner [MVP]
Date Posted: 6/7/2010 4:18:00 PM

Am 08.06.2010 00:05, schrieb Dave Wurtz:
> In my VB.NET application, I'm trying to call a function from a 32-bit,
> non-.NET dll file and I'm having problems. I believe I have the
> correct signature for the dll with:
>
> <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
>[...]
> When I run this, I get the error:
> An exception of type 'System.EntryPointNotFoundException' occurred in
> ProductVision.Windows.Forms.dll but was not handled in user code.
> Additional information: Unable to find an entry point named
> 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.

Maybe the function has a different name. You may want to use Dependency
Walker (<URL:http://www.dependencywalker.com/>) to examine the function
the DLL exports.

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

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Dave Wurtz
Date Posted: 6/8/2010 6:59:00 AM

On Jun 7, 5:16 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
h...@gmx.at> wrote:
> Am 08.06.2010 00:05, schrieb Dave Wurtz:
>
> > In my VB.NET application, I'm trying to call a function from a 32-bit,
> > non-.NET dll file and I'm having problems.  I believe I have the
> > correct signature for the dll with:
>
> > <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
>  >[...]
> > When I run this, I get the error:
> > An exception of type 'System.EntryPointNotFoundException' occurred in
> > ProductVision.Windows.Forms.dll but was not handled in user code.
> > Additional information: Unable to find an entry point named
> > 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.
>
> Maybe the function has a different name.  You may want to use Dependency
> Walker (<URL:http://www.dependencywalker.com/>) to examine the function
> the DLL exports.
>
> --
>   M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>   V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

Thanks for the reply.

As suggested, I downloaded the Dependency Walker program and opened
the DLL. In looking at the function I want to call and selecting
"Undecorate C++ Functions", this is what it shows:

int BuildCompositeFile(char *,char *,char *,char *,char *,char *,int)

Do I have the correct signature defined?

Thanks.
Dave

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Dave Wurtz
Date Posted: 6/17/2010 3:01:00 PM

On Jun 8, 7:56 am, Dave Wurtz <dave_wu...@asdsoftware.com> wrote:
> On Jun 7, 5:16 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
>
>
>
>
>
> h...@gmx.at> wrote:
> > Am 08.06.2010 00:05, schriebDaveWurtz:
>
> > > In my VB.NET application, I'm trying to call a function from a 32-bit,
> > > non-.NET dll file and I'm having problems.  I believe I have the
> > > correct signature for the dll with:
>
> > > <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
> >  >[...]
> > > When I run this, I get the error:
> > > An exception of type 'System.EntryPointNotFoundException' occurred in
> > > ProductVision.Windows.Forms.dll but was not handled in user code.
> > > Additional information: Unable to find an entry point named
> > > 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.
>
> > Maybe the function has a different name.  You may want to use Dependency
> > Walker (<URL:http://www.dependencywalker.com/>) to examine the function
> > the DLL exports.
>
> > --
> >   M S   Herfried K. Wagner
> > M V P  <URL:http://dotnet.mvps.org/>
> >   V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
> Thanks for the reply.
>
> As suggested, I downloaded the Dependency Walker program and opened
> the DLL.  In looking at the function I want to call and selecting
> "Undecorate C++ Functions", this is what it shows:
>
> int BuildCompositeFile(char *,char *,char *,char *,char *,char *,int)
>
> Do I have the correct signature defined?
>
> Thanks.Dave- Hide quoted text -
>
> - Show quoted text -

Can anyone tell me if I have the correct signature defined here? Once
again, Dependency Walker showed the following for the function inside
the DLL that I am trying to call:

int BuildCompositeFile(char *,char *,char *,char *,char *,char *,int)

I have tried to create the equivalent signature in my VB.Net
application:


<System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
_
    Public Shared Function BuildCompositeFile(ByVal szOldFile As
String, _

ByVal szNewFile As String, _

ByVal szCompositeFile As String, _

ByVal szOldPrefix As String, _

ByVal szNewPrefix As String, _

ByVal szCompositePrefix As String, _

ByVal bCheckForChangedImages As Integer) As Integer
    End Function

I must be doing something wrong because when I call the function, I
get the error:

An exception of type 'System.EntryPointNotFoundException' occurred in
ProductVision.Windows.Forms.dll but was not handled in user code.
Additional information: Unable to find an entry point named
'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.

Can someone help me with this please.

Thanks in advance!
Dave

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Armin Zingler
Date Posted: 6/18/2010 7:02:00 AM

Am 17.06.2010 22:57, schrieb Dave Wurtz:
> <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
> _
>     Public Shared Function BuildCompositeFile(ByVal szOldFile As
> String, _
>  
> ByVal szNewFile As String, _
>  
> ByVal szCompositeFile As String, _
>  
> ByVal szOldPrefix As String, _
>  
> ByVal szNewPrefix As String, _
>  
> ByVal szCompositePrefix As String, _
>  
> ByVal bCheckForChangedImages As Integer) As Integer
>     End Function
>
> I must be doing something wrong because when I call the function, I
> get the error:
>
> An exception of type 'System.EntryPointNotFoundException' occurred in
> ProductVision.Windows.Forms.dll but was not handled in user code.
> Additional information: Unable to find an entry point named
> 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.

Try it with
  Declare Function...
with same name and same types.

Also try
  Declare Ansi Function...

--
Armin

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Tom Shelton
Date Posted: 6/18/2010 7:50:00 AM

Dave Wurtz formulated the question :
> On Jun 7, 5:16 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
> h...@gmx.at> wrote:
>> Am 08.06.2010 00:05, schrieb Dave Wurtz:
>>
>>> In my VB.NET application, I'm trying to call a function from a 32-bit,
>>> non-.NET dll file and I'm having problems.  I believe I have the
>>> correct signature for the dll with:
>>
>>> <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
>>>  >[...] When I run this, I get the error:
>>> An exception of type 'System.EntryPointNotFoundException' occurred in
>>> ProductVision.Windows.Forms.dll but was not handled in user code.
>>> Additional information: Unable to find an entry point named
>>> 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.
>>
>> Maybe the function has a different name.  You may want to use Dependency
>> Walker (<URL:http://www.dependencywalker.com/>) to examine the function
>> the DLL exports.
>>
>> --
>>   M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>>   V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
> Thanks for the reply.
>
> As suggested, I downloaded the Dependency Walker program and opened
> the DLL. In looking at the function I want to call and selecting
> "Undecorate C++ Functions", this is what it shows:
>
> int BuildCompositeFile(char *,char *,char *,char *,char *,char *,int)
>
> Do I have the correct signature defined?
>
> Thanks.
> Dave

If the dll is exposing a decorated name, then you must alias the vb
declare to the decorated name....

--
Tom Shelton

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Dave Wurtz
Date Posted: 6/18/2010 12:06:00 PM

On Jun 17, 11:25 pm, Armin Zingler <az.nos...@freenet.de> wrote:
> Am 17.06.2010 22:57, schriebDaveWurtz:
>
>
>
>
>
> > <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
> > _
> >     Public Shared Function BuildCompositeFile(ByVal szOldFile As
> > String, _
>
> > ByVal szNewFile As String, _
>
> > ByVal szCompositeFile As String, _
>
> > ByVal szOldPrefix As String, _
>
> > ByVal szNewPrefix As String, _
>
> > ByVal szCompositePrefix As String, _
>
> > ByVal bCheckForChangedImages As Integer) As Integer
> >     End Function
>
> > I must be doing something wrong because when I call the function, I
> > get the error:
>
> > An exception of type 'System.EntryPointNotFoundException' occurred in
> > ProductVision.Windows.Forms.dll but was not handled in user code.
> > Additional information: Unable to find an entry point named
> > 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.
>
> Try it with
>   Declare Function...
> with same name and same types.
>
> Also try
>   Declare Ansi Function...
>
> --
> Armin- Hide quoted text -
>
> - Show quoted text -

Thanks for the suggestion. Unfortunately, I get the same error
message. This is how I typed it:

Public Declare Function BuildCompositeFile Lib
"asdHTMLCompare.dll" (ByVal szOldFile As System.String, _
ByVal szNewFile As System.String, _
ByVal szCompositeFile As System.String, _
ByVal szOldPrefix As System.String, _
ByVal szNewPrefix As System.String, _
ByVal szCompositePrefix As System.String, _
ByVal bCheckForChangedImages As Integer) As Integer

I also tried Public Declare Ansi/Auto/Unicode Function .... and all of
them throw the same exception:

An exception of type 'System.EntryPointNotFoundException' occurred in
ProductVision.Windows.Forms.dll but was not handled in user code
Additional information: Unable to find an entry point named
'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.

Any other suggestions?

Thanks.
Dave

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Dave Wurtz
Date Posted: 6/18/2010 12:06:00 PM

On Jun 18, 8:47 am, Tom Shelton <tom_shel...@comcast.invalid> wrote:
> DaveWurtzformulated the question :
>
>
>
>
>
> > On Jun 7, 5:16 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
> > h...@gmx.at> wrote:
> >> Am 08.06.2010 00:05, schriebDaveWurtz:
>
> >>> In my VB.NET application, I'm trying to call a function from a 32-bit,
> >>> non-.NET dll file and I'm having problems.  I believe I have the
> >>> correct signature for the dll with:
>
> >>> <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
> >>>  >[...] When I run this, I get the error:
> >>> An exception of type 'System.EntryPointNotFoundException' occurred in
> >>> ProductVision.Windows.Forms.dll but was not handled in user code.
> >>> Additional information: Unable to find an entry point named
> >>> 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.
>
> >> Maybe the function has a different name.  You may want to use Dependency
> >> Walker (<URL:http://www.dependencywalker.com/>) to examine the function
> >> the DLL exports.
>
> >> --
> >>   M S   Herfried K. Wagner
> >> M V P  <URL:http://dotnet.mvps.org/>
> >>   V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
> > Thanks for the reply.
>
> > As suggested, I downloaded the Dependency Walker program and opened
> > the DLL.  In looking at the function I want to call and selecting
> > "Undecorate C++ Functions", this is what it shows:
>
> > int BuildCompositeFile(char *,char *,char *,char *,char *,char *,int)
>
> > Do I have the correct signature defined?
>
> > Thanks.
> >Dave
>
> If the dll is exposing a decorated name, then you must alias the vb
> declare to the decorated name....
>
> --
> Tom Shelton- Hide quoted text -
>
> - Show quoted text -

I don't understand what you are saying. Can you expand on this and/or
show an example?

Thanks.
Dave

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Tom Shelton
Date Posted: 6/18/2010 1:25:00 PM

Dave Wurtz submitted this idea :
> On Jun 18, 8:47 am, Tom Shelton <tom_shel...@comcast.invalid> wrote:
>> DaveWurtzformulated the question :
>>
>>
>>
>>
>>
>>> On Jun 7, 5:16 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
>>> h...@gmx.at> wrote:
>>>> Am 08.06.2010 00:05, schriebDaveWurtz:
>>>>> In my VB.NET application, I'm trying to call a function from a 32-bit,
>>>>> non-.NET dll file and I'm having problems.  I believe I have the
>>>>> correct signature for the dll with:
>>>>> <System.Runtime.InteropServices.DllImportAttribute("asdHTMLCompare.dll")>
>>>>>  >[...] When I run this, I get the error:
>>>>> An exception of type 'System.EntryPointNotFoundException' occurred in
>>>>> ProductVision.Windows.Forms.dll but was not handled in user code.
>>>>> Additional information: Unable to find an entry point named
>>>>> 'BuildCompositeFile' in DLL 'asdHTMLCompare.dll'.
>>>> Maybe the function has a different name.  You may want to use Dependency
>>>> Walker (<URL:http://www.dependencywalker.com/>) to examine the function
>>>> the DLL exports.
>>
>>>> --
>>>>   M S   Herfried K. Wagner
>>>> M V P  <URL:http://dotnet.mvps.org/>
>>>>   V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>>> Thanks for the reply.
>>
>>> As suggested, I downloaded the Dependency Walker program and opened
>>> the DLL.  In looking at the function I want to call and selecting
>>> "Undecorate C++ Functions", this is what it shows:
>>> int BuildCompositeFile(char *,char *,char *,char *,char *,char *,int)
>>> Do I have the correct signature defined?
>>> Thanks.
>>> Dave
>>
>> If the dll is exposing a decorated name, then you must alias the vb
>> declare to the decorated name....
>>
>> --
>> Tom Shelton- Hide quoted text -
>>
>> - Show quoted text -
>
> I don't understand what you are saying. Can you expand on this and/or
> show an example?
>

By default a dll compiled in C++ will mangle the names - this is to
allow overriding of functions.   So, your function BuildCompositeFile
maybe exported as something like ?BuildCompositFile@@YXZ. That isn't
probably the actual name - I the way names are mangaled or decorated
has alot to do with the compiler, and the types being passed. But the
point is, the entery point in the dll is probably NOT
BuildCompositeFile.

You can use dumpbin /exports on your dll to see the actual name table.
So, say the name is as above, then you would need to add an alias to
your VB declare:

Declare Ansi Function BuildCompositFile Lib "asdHtmlCompare.dll" Alias
"?BuildCompositFile@@YXZ" (.....)

HTH

--
Tom Shelton

Re: Help Calling A Function from a 32-bit non-.NET DLL
From: Herfried K. Wagner [MVP]
Date Posted: 6/18/2010 1:31:00 PM

Am 18.06.2010 20:03, schrieb Dave Wurtz:
>> If the dll is exposing a decorated name, then you must alias the vb
>> declare to the decorated name....
>
> I don't understand what you are saying. Can you expand on this and/or
> show an example?

Use the name you see prior to choosing to undecorate the function.

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

Results 1 - 10 of 12 Next Page »

 

Would you like to track this thread?

By adding this News Thread to your Favorites Area you can refer to it later with just a click of the mouse. Also you can optionally be notified instantly whenever there are any replies posted to this Thread. To add this Thread to your Favorites Area just click on the red arrow next to the subject of the thread above Add this thread to My Favorites.



ASP.NET Chart Control.
Charts from your Database.
Live Demo & FREE Trial!

ASP ArticlesThis category has been added to your weekly newsletter
ASP Web Sites
ADSI & WSH BooksThis category has been added to your weekly newsletter
FREE ComponentsThis category has been added to your weekly newsletter
ASP EventsThis category has been added to your weekly newsletter
ASP HeadlinesThis category has been added to your weekly newsletter

CSharp ArticlesThis category has been added to your weekly newsletter
C# Web SitesThis category has been added to your weekly newsletter

SQL ArticlesThis category has been added to your weekly newsletter
SQL Events
SQL HeadlinesThis category has been added to your weekly newsletter
SQL Jobs

Jobs in CaliforniaThis category has been added to your weekly newsletter

XML ArticlesThis category has been added to your weekly newsletter
XML BooksThis category has been added to your weekly newsletter
XML Web Sites
XML Tutorials

free asp host

"Alex Homer"This search has been added to your weekly newsletter

Edit My Favorites Edit Profile & Favorites

 

 

 

 

 




Developersdex Home | ASP | C# | SQL | VB | XML | Gurus
Add Your Link | Add Your Code | FAQ | Advertise | Link To Us | Contact Us |
Copyright © 2010 Developersdex™. All rights reserved.