SoftingIndustrial / OPC-Classic-SDK

Softing OPC Classic SDK
https://industrial.softing.com/de/produkte/opc-ua-und-opc-classic-sdks.html
MIT License
53 stars 22 forks source link

Can't start .NET test server via COM #15

Closed milosmatovic closed 1 year ago

milosmatovic commented 1 year ago

Issue Description

When attempting to start C# test server using OPC classic demo client (or any other client), the application starts but fails to connect with error 0x80080005: Failed to create OPC server object.

Local server listed in OPC client: (please note that VersionIndependentProgId is not listed there for some reason, not sure if this would affect things) image Error details: image

The application seems to be registered OK in windows registry: image image image

Environment

Windows 10 opc-core-components-redistributables-3.00.108-20191220 Built TBN dll with .NET framework 4.6.1 image

DCOMCNFG Settings image image image image image image image

I haven't changed any of the source code before building, could it be something with the instance setup that requires changing? i.e. user permissions image

ro0ter commented 1 year ago

Hello @milosmatovic

Please make sure you are using x86 or x64 architecture.

AGAIN: NEVER USE THE ANYCPU CONFIGURATION FOR AN APPLICATION CONTAINING AN OPC SERVER.

Now, to fix your deeds... (your dev system)

  1. Either rename your .NET OPC SERVER, however you'll remain with an unusable OPC server in the server list...
  2. Or compile the server as (A) x64, then run it with (1) /unregserver, then with (2) /reserver and then again with (3) /unregserver. Afterwards compile as (B) x86 and run it with the three (1,2,3) parameters.

The reason behind this advice is that the .NET AnyCpu-built applications always start as x86 processes, then - if the system architecture is x64 - it just-in-tine switches to x64, spawning itself as x64 and immediately exiting (so the x86 process exits, the x64 remains). This is catastrophic for the DCOM Governor, since it loses its handle to the process it previously spawned with CoCreateInstance.

If you are really paying attention, you'll notice your process starts times and again every DCOM_TIMEOUT interval, yet it stops because the XML DA port is in use by the first server instance.

If your server would not have started at all, the XML-DA port should have been already used by another server. Not the case here, as well all see.

So please, read the manual next time before opening an issue.

Additional note: With the Softing OPC Clasic Demo Client you cannot force the DA version through the browsing mode, you'll have to work with the server properties. And yes, you'll have to select the server nose (left-click it) before right-clicking it... (-: don't ask

Regards, The Captain.

milosmatovic commented 1 year ago

Hi @ro0ter , thank you very much for the quick and detailed response. Building as x64 has indeed worked! Closing the ticket now.