Page 1 of 1
					
				Multithreading support
				Posted: Wed  17 Nov 2010 21:13
				by jacoch2
				Hi. I'm currently using the evaluation version of SecureBridge for a project I'm working on. It's a multithreaded application that will load DLLs to execute Sftp file operations.
I have created a small project to test SecureBridge. It's quite simple. A main application that starts a thread. In the execute procedure of the thread, I'm loading/unloading several times a DLL. That DLL just initializes TScSSHClient, TScSFTPClient and TScRegStorage. Everything works fine the first time the DLL is loaded/unloaded. On the second try, FreeLibrary just hang. No crash or anything. It just hangs. The problem appears as soon as a SecureBridge file is in the uses clause of the DLL.
Is SecureBridge supposed to work in such scenario? Could the problem be due to the evaluation version that display a message box when loading the DLL? Thanks in advance for your help. Regards, Jacques.
			 
			
					
				
				Posted: Tue  23 Nov 2010 09:32
				by Dimon
				SecureBridge allows to work with dll without any problems.
Maybe this problem is connected with using SecureBridge Trial Edition. To avoid the trial message, please open the "HKEY_LOCAL_MACHINE\SOFTWARE\Devart\SecureBridge" registry key and create new DWORD value with the 'ShowTrialMessage' name and value 0.
			 
			
					
				
				Posted: Tue  23 Nov 2010 10:44
				by jacoch2
				Thanks for the reply. I tried to set the registry entry. The dialog doesn't popup any more. But I still have the trouble (using Delphi 2009 on Win7).
This DLL works fine:
library Test;
uses
  SysUtils,
  Classes;
{$R *.res}
function ActionExecute: Integer; stdcall;
begin
  Result := 0;
end;
exports
  ActionExecute;
begin
end.
And that one hangs on FreeLibrary the second time the DLL is loaded/unloaded.
library Test;
uses
  SysUtils,
  Classes,
  ScBridge,
  ScSSHClient,
  ScSFTPClient,
  ScSFTPUtils;
{$R *.res}
function ActionExecute: Integer; stdcall;
begin
  Result := 0;
end;
exports
  ActionExecute;
begin
end.
The only difference is that the second one has SecureBridge files in use clause. Could you try to build such library and dynamically load it and free it 2 times (using code below)? On my computer, Delphi hangs on second FreeLibrary.
  DllPath := ExtractFilePath(Application.ExeName) + 'Test.dll';
  NextLib := LoadLibrary(PChar(DllPath));
  if NextLib = 0 then exit;
  @ExecAction := GetProcAddress(NextLib, 'ActionExecute');
  if @ExecAction  Nil then
  begin
  end;
  FreeLibrary(NextLib);
  DllPath := ExtractFilePath(Application.ExeName) + 'Test.dll';
  NextLib := LoadLibrary(PChar(DllPath));
  if NextLib = 0 then exit;
  @ExecAction := GetProcAddress(NextLib, 'ActionExecute');
  if @ExecAction  Nil then
  begin
  end;
  FreeLibrary(NextLib);
Thanks in advance for your help.
			 
			
					
				
				Posted: Wed  24 Nov 2010 10:26
				by Dimon
				We have investigated this problem. The problem arises because when you use trial version of SecureBridge, your dll needs to use the sbridge120.bpl package, even if it is built without run-time packages. On unloading of dll an unloading of trial bpl occurs and then application hangs. In order to solve the problem you should use standard version of SecureBridge.
			 
			
					
				
				Posted: Wed  24 Nov 2010 17:35
				by jacoch2
				Thanks for the investigation. Glad to hear that problem should not appear with full version. I can then continue my evaluation with other features.
			 
			
					
				
				Posted: Thu  25 Nov 2010 08:27
				by Dimon
				Feel free to contact us if you have any further questions about SecureBridge.