Professional OPC
Development Tools

logos

OPC UA using PHP

More
20 Sep 2017 06:56 - 20 Sep 2017 06:58 #5533 by support
Replied by support on topic OPC UA using PHP
Thank you. I was now able to reproduce the error. It only happens when just "PHP" is used to start the program (and from the plain CMD, not for example from the FAR Manager which is what I have used before).

This is a bug on our side. It comes, however, from an OPC Foundation code. In some cases, it attempts to strip off last 4 characters of the command-line argument zero, without considering all the possible cases. We will fix it in the upcoming QuickOPC version (2017.2). For now, there are workarounds:

1a. Use PHP.EXE to start the program, and not just PHP (in this case you do not have to put in the full path)
1b. Use the full path to start the program.

2. Add following at the beginning of your program:
$ClientConfiguration = new COM("OpcLabs.EasyOpc.UA.EasyUAClientConfiguration");
$ClientConfiguration->SharedParameters->EngineParameters->ConfigurationSources = 2;
3. There is probably a workaround that would consist of placing one or two extra config files (for QuickOPC) into your PHP directory. It would take me some time to design and verify, so I am not placing it here for now, but if the above workaround were not suitable for you, let me know.

I apologize for the inconvenience - and thank you once again for your help in finding the root cause.

Best regards
Last edit: 20 Sep 2017 06:58 by support. Reason: typo
The following user(s) said Thank You: kgulmer

Please Log in or Create an account to join the conversation.

More
19 Sep 2017 17:26 #5529 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
1. I am not trying to edit xml.

2. Start from CMD directly using just PHP (not php.exe).

php "C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\ExamplesCom\PHP\Console\UADocExamples\_EasyUAClient.Read.Main.php"
However, after you mention this, I tried from the php.exe and there is no error

"C:\Program Files (x86)\PHP\v5.5\php.exe" "C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\ExamplesCom\PHP\Console\UADocExamples\_EasyUAClient.Read.Main.php"

Is this normal behavior? Hard links to these commands are impractical.

Please Log in or Create an account to join the conversation.

More
19 Sep 2017 17:05 #5528 by support
Replied by support on topic OPC UA using PHP
Yes, this is what I wanted - perfect, thank you! I can already see where it is coming from. Before I decide further, can you please tell:

1) Are you trying to make some configuration using the .config (XML) file?

2) how are you starting the PHP? From the CMD, or some other way? If from CMD, how precisely? - Specifically, do you have just PHP at the end, or PHP.EXE?

Thank you

Please Log in or Create an account to join the conversation.

More
19 Sep 2017 15:10 #5525 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
I think the call stack information for both errors is contained in the quoted sections of the previous post. But in case it's not the same, here is the information from the Call Stack window pasted below:
>	mscorlib.dll!string.Substring(int startIndex, int length)	Unknown
 	Opc.Ua.Core!Opc.Ua.ApplicationConfiguration.GetFilePathFromAppConfig(string sectionName)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.AppConfigSdkConfigurationProvider.GetConfiguration(Opc.Ua.Configuration.ApplicationInstance sdkApplicationInstance, out Opc.Ua.ApplicationConfiguration sdkApplicationConfiguration)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.MakeSdkApplicationConfiguration(Opc.Ua.Configuration.ApplicationInstance sdkApplicationInstance, out Opc.Ua.ApplicationConfiguration sdkApplicationConfiguration)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.CreateSdkApplicationConfiguration(Opc.Ua.Configuration.ApplicationInstance sdkApplicationInstance, out Opc.Ua.ApplicationConfiguration sdkApplicationConfiguration)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.CreateSdkApplicationInstance(out Opc.Ua.Configuration.ApplicationInstance sdkApplicationInstance, out Opc.Ua.ApplicationConfiguration sdkApplicationConfiguration)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.MakeSdkApplicationInstance(out Opc.Ua.Configuration.ApplicationInstance sdkApplicationInstance)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.InternalConnect()	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.Connect()	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.ExternalConnect()	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAEngineBase.PerformGuardedOperation(string name, System.Action action)	Unknown
 	OpcLabs.EasyOpcUA.dll!OpcLabs.EasyOpc.UA.Toolkit.UAClientEngineBase.StartGuardedOperation.AnonymousMethod__0()	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Messaging.IMessageSink replySink)	Unknown
 	mscorlib.dll!System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(object o)	Unknown
 	mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)	Unknown
 	mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()	Unknown
 	mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()	Unknown
 	mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()	Unknown

Please Log in or Create an account to join the conversation.

More
19 Sep 2017 14:07 #5524 by support
Replied by support on topic OPC UA using PHP
This is great. We are getting there but we are not there yet. Do not worry about the Visual Studio knowledge. Only the first exception is probably relevant to us. I need the call stack, and I can think of following ways to get it:

1) when the exception is thrown, you may get a little popup titled "Exception Thrown", and in it, there is a link that says "Copy Details". Click on it, and then send us the content of the clipboard.

2) In the Quick Watch window you have, select the "StackTrace" row, and then click the drop-down button at the right of it, and select "Text Visualizer". Then, send us the resulting text from the visualizer window.

3) When the exception occurs, Debug -> Windows -> Call Stack from the VS menu. Then, right-click inside the Call Stack window, select "Select All", and send us the content of the clipboard.

Thank you in advance, and best regards

Please Log in or Create an account to join the conversation.

More
19 Sep 2017 12:43 #5523 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
First of all, I don't have much (any) experience with Visual Studio, so forgive me for being a little clueless with it's debugger.

We had selected 'System.ArgumentException' as instructed, but it is not breaking into a debugger (see this image link . I went ahead and added checkmarks next to the two exception types that we are seeing: 'System.ArgumentOutOfRangeException' and 'System.Reflection.TargetInvocationException'. With these checked, Visual Studio kicked into Break Mode with the following additional details:

- Imgur Link : System.ArgumentOutOfRangeException
System.ArgumentOutOfRangeException occurred
  HResult=0x80131502
  Message=Length cannot be less than zero.
  Source=mscorlib
  StackTrace:
   at System.String.Substring(Int32 startIndex, Int32 length)

- Imgur Link : System.Reflection.TargetInvocationException
System.Reflection.TargetInvocationException occurred
  HResult=0x80131604
  Message=Exception has been thrown by the target of an invocation.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
 
Inner Exception 1:
ArgumentOutOfRangeException: Length cannot be less than zero.

Please Log in or Create an account to join the conversation.

More
19 Sep 2017 06:38 #5522 by support
Replied by support on topic OPC UA using PHP
Thank you very much, this looks better. But it does not help me yet. I was expecting that at the time the exception is thrown, it would break into the debugger, and give you the chance to obtain the call stack (and possibly other details).

The exception type seems to be slightly different from what I expected, although it is still a subtype of 'System.ArgumentAxception'. It is 'System.ArgumentOutOfRangeException' instead. Can you please make sure that this type is also explicitly checked in the Exception settings (Step 2 in the original instructions)?

Best regards

Please Log in or Create an account to join the conversation.

More
18 Sep 2017 16:06 #5521 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
Same settings, "Just My Code" disabled, looks like the exception was caught here:

'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\Assemblies\net452\OpcLabs.EasyOpcUA.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\Assemblies\net452\OpcLabs.BaseLib.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Opc.Ua.Client'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Opc.Ua.Core'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Opc.Ua.Configuration'. Cannot find or open the PDB file.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\Assemblies\net452\OpcLabs.BaseLibForms.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.ArgumentOutOfRangeException' in mscorlib.dll
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.ArgumentOutOfRangeException' in mscorlib.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
The program '[236] php.exe' has exited with code 0 (0x0).

Please Log in or Create an account to join the conversation.

More
18 Sep 2017 15:41 #5520 by support
Replied by support on topic OPC UA using PHP
OK that's not good. What bothers me is that you do not even see the exception listed in the debug output on a separate line? If so, is the "Managed (v4.6, v4.5, v4.0)" code type really checked (as described in Step 4)?

And, can you please disable "Just My Code": In Debug -> Options, General: uncheck the corresponding setting. It may also be worth enabling the "Use Manage Compatibility Mode"

Regards

Please Log in or Create an account to join the conversation.

More
18 Sep 2017 15:26 #5519 by kgulmer
Replied by kgulmer on topic OPC UA using PHP
I've followed the instructions, but it looks to me like the exception may not be caught:

'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\Assemblies\net452\OpcLabs.EasyOpcUA.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\Assemblies\net452\OpcLabs.BaseLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Opc.Ua.Client'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Opc.Ua.Core'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'Opc.Ua.Configuration'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files (x86)\OPC Labs QuickOPC 2017.1\Assemblies\net452\OpcLabs.BaseLibForms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'php.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[17192] php.exe' has exited with code 0 (0x0).

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.215 seconds

      

 Recommend this on Google