LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 1172, only if EXE is running as Windows service

Solved!
Go to solution

Hello Everyone,

 

I'm seeking your help for this issue wherein only if I run an EXE as service, it gives me error 1172 with following error source (string):

"Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.ComponentModel.Win32Exception: The handle is invalid <append><b>System.ComponentModel.Win32Exception</b> in WinDefendImage(Writer)_LocalDLL.vi"

 

I'm using .NET assemblies in my code. Also, both source code and EXE runs fine on the computer (with LabVIEW development environment installed). Its only when the EXE is ran as an service I am getting error. Below is the VI snippet (trimmed) for your perusal and the block highlighted in RED box is throwing error 1172.

VI Snippet.png

I'm using VI from this link as a starting point and created LabVIEW service using method explain here.

There is no issue with creating/running service. After service is STARTED, i can see LabVIEW exe is running (in task manager). I modified the LabVIEW code to write a text file (with debug) data and that is how I determined that the invoke node is throwing error.

 

 

Looking for guidance on how to debug/fix the issue.

0 Kudos
Message 1 of 4
(2,091 Views)

Also, I found 'mscorlib' and 'System.Drawing' as part of Dependencies.

 

mscorlib in Dependencies.png

 

I already tried including the System.Drawing.dll in project and linked it with .NET constructor nodes (in LabVIEW code) but not sure if I should include anything else.

0 Kudos
Message 2 of 4
(2,071 Views)
Solution
Accepted by topic author scofield

A service runs in a special console session that is headless. The CopyFromScreen method likely tries to create a screen device context that the underlaying Windows API functions can't create since there is effectively no screen to copy anything from!

Rolf Kalbermatter
My Blog
Message 3 of 4
(2,057 Views)

Hi Rolf,

 

Thank you for taking your time to look into the issue.

I'll wait for some time for any other comments or a workaround or else, I'll close this thread and marked it as solved [or cannot be solved :-)].

0 Kudos
Message 4 of 4
(2,039 Views)