9:33, EET
January 22, 2013
Hi all Prosys Sentrol experts,
I developped (using Delphi XE2) a Windows 32 bits App hosting an OPC server. (Based on
the Prosys Sentrol Delphi library (lib160) ).
This Windows application works fine. The OPC server can be registered with the command line parameter /regserver.
I can connect any OPC Client application to my OPC Server App. (ie the Prosys OPC Client v2.0.0.4 or the dOPC Explorer v1.6.2.20 from www://kassl.de)
Both test clients see the registered OPC server and can successfully connect to it.
OK, that’s the working part… Now let’s look at the problem part:
I then transform my Windows standard application into a Windows Service application.
(I changed the DCOM GUID for this new “OPC Server as a Service”)
(The Delphi compiler generates an .exe that has to be run with the /install command line parameter to install the service. It can then be run using the dedicated service administrative tool)
I installed my service and started it.
According to the debugging output, it is correctly running inside the started service.
Now I tried to register it: and here started the problems…
I first tried to register it with the /regserver command line parameter.
(The GUID appears in the registry, linked to the .exe file used to install the service).
But when I start a client application, it does NOT show the OPC server hosted by the running service !
I also read somewhere (on the OPCFoundation.org forum, in a thread about the OPCEnum.exe started as a service), that it shouldn’t be registered with /regserver but with the /Service command line parameter. So I unregistered my service OPC Server (/unregserver) I deleted the registry key related to my GUID and tried to register it with the /Service command line parameter… But I got the same final result: The OPC server is not seen by the OPC test Clients apps….
Could you help me to successfully register my correctly installed and running “OPC Server as a service” ?
I found nothing in the Prosys Sentrol SDK tutorial or help files about this problem.
Thanks a lot for any help or suggestion.
PS: I’m using Delphi XE2, the service application/service were generated in 32 bits. And I’m running them on Windows 7.
Pierre-François Culand
Software Developer / Ing inf dipl EPFL
Switzerland
Web: http://www.vkvision.ch
11:03, EET
December 21, 2011
The OPC Simulation Server includes a sample service project. If you develop yours according to it, you can use the ‘/install’ switch to register the server.
11:05, EET
January 22, 2013
Jouni Aro said
The OPC Simulation Server includes a sample service project. If you develop yours according to it, you can use the ‘/install’ switch to register the server.
Thanks. I’ve coded my service this way and the registration of my OPC Server works now in my Service.
Nevertheless, I now have a problem when a Client try to connect to my OPC server. The Client hangs when connecting with the service version of my OPC server…
I have checked that my OPC server is really running, it’s ok, his state is logged as OPC_STATUS_RUNNING.
If I handle the OnConnect event property, I notice it is never raised on my OPCProvider when a Client try to connect with it.
I have also activated the ActivityLog but only the “Server started.” event appears logged in the file.
Is there a possible insuffisant right issue that could explain a possible DCOM malfunction between the Client and my server in a service ? (I’m running Windows 7)
How can I try to debug this ? Any idea ? TY
Pierre-François Culand
Software Developer / Ing inf dipl EPFL
Switzerland
Web: http://www.vkvision.ch
11:17, EET
December 21, 2011
12:15, EET
January 22, 2013
Jouni Aro said
Are you using a full or evaluation edition? The Sentrol evaluation edition does not enable servers to work in service mode.
it’s a full Sentrol 6.1.10 professional edition (with source code). Moreover I’ve compiled the simulation server and ran it. The Clients does not hang with it. The problem occurs only with my service.
I might have forgotten or miscopied something when transforming my server standard app in a service… but I didn’t find what… The standard OPC server app works fine.
Pierre-François Culand
Software Developer / Ing inf dipl EPFL
Switzerland
Web: http://www.vkvision.ch
13:46, EET
December 21, 2011
OK, yeah it’s probably that you’ve missed the DelayInitialize, which needs to be used with Delphi service projects.
This is from the project file of the Simulation Service:
{$IFDEF CONDITIONALEXPRESSIONS} {$IF RTLVersion >= 18.0} {$DEFINE D2006_OR_LATER} {$IFEND} {$ENDIF} {$IFDEF D2006_OR_LATER} // Windows 2003 Server requires StartServiceCtrlDispatcher to be // called before CoRegisterClassObject, which can be called indirectly // by Application.Initialize. TServiceApplication.DelayInitialize allows // Application.Initialize to be called from TService.Main (after // StartServiceCtrlDispatcher has been called). // // Delayed initialization of the Application object may affect // events which then occur prior to initialization, such as // TService.OnCreate. It is only recommended if the ServiceApplication // registers a class object with OLE and is intended for use with // Windows 2003 Server. // // So, compile with Delphi 2006 or newer if you need to support // Windows 2003 Server! Application.DelayInitialize := True; if not Application.DelayInitialize or Application.Installing then {$ENDIF} Application.Initialize;
15:53, EET
January 22, 2013
Jouni Aro said
OK, yeah it’s probably that you’ve missed the DelayInitialize, which needs to be used with Delphi service projects.
This is from the project file of the Simulation Service:
Thanks for your support.
You were right, I didn’t copy this code in my service and didn’t set Application.DelayInitialize to True…
But this was because I read this was necessary only to run under Windows 2003 server. So I thought this wasn’t necessary to run on my Windows 7 64 bits PC.
Nevertheless I now made the change and inserted your code exactly like in the Simulation Service project….
…And the problem still remains the same !…
My server is correctly registered and started, but when a client try to connect to my OPC server, the client app freezes and I have to kill it.
My OPC Server only logs it was started and It does not handle the OnConnect event.
Pierre-François Culand
Software Developer / Ing inf dipl EPFL
Switzerland
Web: http://www.vkvision.ch
16:32, EET
December 21, 2011
8:49, EET
January 22, 2013
Jouni Aro said
If you can, please send your project to our support so I will take a look.
So I did…
Thanks.
Pierre-François Culand
Software Developer / Ing inf dipl EPFL
Switzerland
Web: http://www.vkvision.ch
10:39, EET
December 21, 2011
12:58, EET
January 22, 2013
Jouni Aro said
Turned out to be related to calling TService.LogMessage, which gives an Access Violation. So this is a project problem.
Yes, everything is now OK, my OPC server as a service is working fine.
Thank you again for your help.
Pierre-François Culand
Software Developer / Ing inf dipl EPFL
Switzerland
Web: http://www.vkvision.ch
Most Users Ever Online: 1919
Currently Online:
25 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 734
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1523
Posts: 6449
Newest Members:
christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16, edgardo3518Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1