Recent

Author Topic: [SOLVED] Connection to instrument via COM fails  (Read 3766 times)

Eclipticon

  • Jr. Member
  • **
  • Posts: 51
[SOLVED] Connection to instrument via COM fails
« on: August 22, 2014, 10:02:02 am »
Good morning,

in a Lazarus project, I am using a COM interface to connect to an external device that is connected to the computer running the software via TCP/IP. I am posting this, because on one system this connection fails, mysteriously.

From the manufacturer, I have received an instrument.dll and an instrument.tlb. Unfortunately, details and code are subject to a confidentiality agreement, so I can only provide pseudocode.

I have two minimal examples, one on Free Pascal:

Code: [Select]
uses
   Instrument_TLB; // Imported via the Lazarus "Import Type Library" function from the .tlb or the .dll

[...]

procedure TForm1.FormCreate(Sender: TObject);
begin
  AInstrument := CoInstrument.Create;
  if AInstrument.Connected then ...
end;

and one on Visual Basic, provided by the manufacturer:

Code: [Select]
Private Sub Form_Load()
   Set theInstrument = New Instrument
   If theInstrument.Connected Then ...
End Sub

This VB6 project has the instrument.dll as a reference.

Both the executables as well als the instrument.dll are 32bit. The behaviour on different computers is as follows (supplemented with information from Sysinternals Process Explorer):

  • System A (Windows XP, 32bit, used for compilation): Both the FP and the VB executable work as expected, a connection can be established. In Process Explorer, both executables have one thread with instrument.dll and the TCP/IP connection can be seen to be up.
  • System B (Windows 7, 64bit): Both the FP and the VB executable work as expected, a connection can be established. Process Explorer was not used.
  • System C (Windows 7, 64bit): The VB executable works as expected, a connection can be established. In Process Explorer the VB executable has one thread with instrument.dll and the TCP/IP connection can be seen to be up. The FP executable can NOT connect, there are two threads with instrument.dll and no TCP/IP connection seen in Process Explorer.

What I just do not get is why the minimal example with VB6 works fine while the (essentially identical) example on FP does not work on this one system. I know that based on the little information I am able to give, no one can come up with a "solution" - however, advice on how to investigate this problem further, what tools to use for debugging would be highly appreciated!

Thanks for your time.
« Last Edit: August 22, 2014, 06:43:44 pm by Eclipticon »
Lazarus 1.2.4 on Win XP/7 Virtual Machine

Laksen

  • Hero Member
  • *****
  • Posts: 662
    • J-Software
Re: Connection to instrument via COM fails
« Reply #1 on: August 22, 2014, 10:11:23 am »
Do you know what the difference between system b and c is?

Did you compile for i386 or x86_64?

Eclipticon

  • Jr. Member
  • **
  • Posts: 51
Re: Connection to instrument via COM fails
« Reply #2 on: August 22, 2014, 10:16:45 am »
Do you know what the difference between system b and c is?

There are countless differences in hardware and software on systems B and C - which could explain if both the VB6 Test and the FP Test fail, but as the VB6 test works, the interface itself seems to be ok ...

Did you compile for i386 or x86_64?

It was compiled on a i386 system, so i386.
Lazarus 1.2.4 on Win XP/7 Virtual Machine

Laksen

  • Hero Member
  • *****
  • Posts: 662
    • J-Software
Re: Connection to instrument via COM fails
« Reply #3 on: August 22, 2014, 04:39:35 pm »
One of the most obvious would be to know if the regional settings of system b and c are different? Comma seperator, etc.

Eclipticon

  • Jr. Member
  • **
  • Posts: 51
Re: Connection to instrument via COM fails
« Reply #4 on: August 22, 2014, 05:43:16 pm »
One of the most obvious would be to know if the regional settings of system b and c are different? Comma seperator, etc.

I had not checked this before, but they are identical - both systems B and C are set to "German (Germany)".
Lazarus 1.2.4 on Win XP/7 Virtual Machine

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: Connection to instrument via COM fails
« Reply #5 on: August 22, 2014, 05:49:36 pm »
maybe firewall / antivirus settings also compare the hosts files on both systems
« Last Edit: August 22, 2014, 05:53:05 pm by Never »
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Eclipticon

  • Jr. Member
  • **
  • Posts: 51
Re: Connection to instrument via COM fails
« Reply #6 on: August 22, 2014, 06:37:57 pm »
Hi,

it was not the firewall, but your advice checking the firewall made me have a look at the IP addresses again - it turns out there was 3 times the correct one in the registry and one time a wrong one (in HKLM\SOFTWARE\WOW6432Node\...).

Correcting the wrong one AND starting the program in Windows 7 compatibility mode (on windows 7?) fixed the error. I just need to understand now, why ... especially why the VB test program runs without problems.
« Last Edit: August 22, 2014, 06:44:15 pm by Eclipticon »
Lazarus 1.2.4 on Win XP/7 Virtual Machine

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: [SOLVED] Connection to instrument via COM fails
« Reply #7 on: August 22, 2014, 07:14:21 pm »
i'm glad i was helpfull.
just a possibility .................
your server costandly brodcasting  a message on a specific port (usualy udp port) then the vb app just need to listen to the correct port to start the communication but......... this is just a quess
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

 

TinyPortal © 2005-2018