Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread client server connection in dll
Tue, Oct 28 2008 11:19 PMPermanent Link

Yury
I use database connection in my dll. There is dll function which returns fields value as a
result. It works fine unless I use remote database connection to DBISAM server. When I
close applicaton which calls that dll function it freezes. It seems like connection to
server cannot be released. I would really appreciate any suggestion.

I found similar problem in this topic:
http://www.elevatesoft.com/newsgrp?action=openmsg&group=12&msg=5434&page=1#msg5434
Wed, Oct 29 2008 2:39 AMPermanent Link

Yury
I am using version 3.30
Wed, Oct 29 2008 1:19 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Yury,

<< I use database connection in my dll. There is dll function which returns
fields value as a result. It works fine unless I use remote database
connection to DBISAM server. When I close applicaton which calls that dll
function it freezes. It seems like connection to server cannot be released.
I would really appreciate any suggestion. >>

What does the actual code look like ?  Are you using a separate set of
DBISAM components in the DLL and not passing any DBISAM component references
to the DLL ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Oct 29 2008 7:37 PMPermanent Link

"Yury"
> Yury,
>
> << I use database connection in my dll. There is dll function which
> returns fields value as a result. It works fine unless I use remote
> database connection to DBISAM server. When I close applicaton which calls
> that dll function it freezes. It seems like connection to server cannot be
> released. I would really appreciate any suggestion. >>
>
> What does the actual code look like ?  Are you using a separate set of
> DBISAM components in the DLL and not passing any DBISAM component
> references to the DLL ?

Thank you for your reply, I posted archive with my test project to binaries
news group.

Thu, Oct 30 2008 5:58 PMPermanent Link

"Al Vas"
Hi Tim,

Are you able to help us with this issue?  We don't believe we are passing
any DBISAM component references and are using a separate set of components.
Yury has created a sample application which duplicates the issue and has
placed it in binaries.  Could you please have a look and advise.  We are
ourely waiting on this issue to release our latest version out to clients.

Thanks Tim

Alex

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:2CDAA8C5-0FF7-41E3-B637-10C9E99881D4@news.elevatesoft.com...
> Yury,
>
> << I use database connection in my dll. There is dll function which
> returns fields value as a result. It works fine unless I use remote
> database connection to DBISAM server. When I close applicaton which calls
> that dll function it freezes. It seems like connection to server cannot be
> released. I would really appreciate any suggestion. >>
>
> What does the actual code look like ?  Are you using a separate set of
> DBISAM components in the DLL and not passing any DBISAM component
> references to the DLL ?
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
>
Thu, Oct 30 2008 8:01 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Alex,

<< Are you able to help us with this issue?  We don't believe we are passing
any DBISAM component references and are using a separate set of components.
Yury has created a sample application which duplicates the issue and has
placed it in binaries.  Could you please have a look and advise.  We are
ourely waiting on this issue to release our latest version out to clients.
>>

I'm still looking at it.  I just got it this afternoon, and have a lot of
projects coming in today that needed looking at and debugging, so it's going
to take a little while longer.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Oct 30 2008 8:11 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Yury,

<< Thank you for your reply, I posted archive with my test project to
binaries news group. >>

Okay, I'm not sure what the issue is exactly, but there's a problem with the
Winsock layer when using a statically-loaded DLL like that.  It probably has
something to do with the Winsock layer getting unloaded prior to the DBISAM
engine cleaning up its connection.  Basically a WaitForData is returning an
error when it shouldn't be, and that is throwing DBISAM for a loop because
it doesn't expect it.

The workaround is this:

type
 TForm1 = class(TForm)
 Button1: TButton;
 Label1: TLabel;
 procedure Button1Click(Sender: TObject);
 private
 { Private declarations }
 public
 { Public declarations }
 end;

  TTestFunc = function : Integer; stdcall; // external
'c:\yury\DLL\MyLib.dll ';

var
 Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  MyLib: THandle;
  MyFunc: TTestFunc;
begin
  MyLib:=LoadLibrary('c:\yury\DLL\MyLib.dll');
  MyFunc:=GetProcAddress(MyLib,'Test1');
Label1.Caption := IntToStr(MyFunc);
  FreeLibrary(MyLib);
end;

Just load and unload the DLL dynamically, and make the call that way.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, Nov 2 2008 6:49 PMPermanent Link

"Yury"
> Yury,
>
> << Thank you for your reply, I posted archive with my test project to
> binaries news group. >>
>
> Okay, I'm not sure what the issue is exactly, but there's a problem with
> the Winsock layer when using a statically-loaded DLL like that.  It
> probably has something to do with the Winsock layer getting unloaded prior
> to the DBISAM engine cleaning up its connection.  Basically a WaitForData
> is returning an error when it shouldn't be, and that is throwing DBISAM
> for a loop because it doesn't expect it.
>
> The workaround is this:
> ........

Thank you very much Tim. It works for me now. The reason we create that dll
is integration with our business partner software. They use VB.NET. Could
you please advise how they can implement dynamic call of our dll. I asked
them to send me their source code. Please have a look at their reply below.

This Function finds your dll location.

<DllImport("kernel32.dll", EntryPoint:="LoadLibraryA", SetLastError:=True, _
    CharSet:=CharSet.Unicode, ExactSpelling:=True, _
    CallingConvention:=CallingConvention.StdCall)> _
    Public Shared Function LoadFunctionPath(ByVal Path As IntPtr) As IntPtr
       ' Leave the body of the function empty.
   End Function

This part loads the dll EmployeeNew functions when needed.

   <DllImport("favourHROHS.dll", EntryPoint:="EmployeeNew",
SetLastError:=True, _
    CharSet:=CharSet.Unicode, ExactSpelling:=True, _
    CallingConvention:=CallingConvention.StdCall)> _
    Public Shared Function EmployeeNew(ByVal src As IntPtr) As IntPtr
       ' Leave the body of the function empty.
   End Function
Code to call DLLImport function. This example used in all Function calls of
your Dll.

InputPTR = Marshal.StringToHGlobalAnsi(Input)
Outputintprt = EmployeeNew(InputPTR)
Result = Marshal.PtrToStringAnsi(Outputintprt)


Mon, Nov 3 2008 12:47 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Yury,

<< Thank you very much Tim. It works for me now. The reason we create that
dll is integration with our business partner software. They use VB.NET.
Could you please advise how they can implement dynamic call of our dll. I
asked them to send me their source code. Please have a look at their reply
below. >>

You can find this information out via a Google search.  Just search on
"VB.NET calling DLLs".

--
Tim Young
Elevate Software
www.elevatesoft.com

Image