Problem Statement
A WinCC 6.2 SP2 runtime picture is configured with a Button object named Button9 on screen @SCREEN.@WIN13:@BUTTONS11. The mouse-click event invokes a global C-Action that calls startSimulation() to launch S7-PLCSIM via ProgramExecute("s7wsvapx.exe"). The moment the operator clicks the button, the runtime does not execute the action. Instead, the PDLRuntimeSystem raises two consecutive OnErrorExecute() diagnostic frames inside the GSC Runtime window. The frames reference an internal pseudo-name @a85, an attribute named inButton9, and two distinct error identifiers (1007006 and 1007001). The intended action of starting PLCSim never occurs.
This article reconstructs the two failure paths, maps them to documented WinCC runtime error categories per the official Siemens configuration error interpretation guide, and provides the exact remediation steps required to clear the fault and recover normal C-Action execution on a WinCC 6.x / 7.x picture window.
Reproduction Environment
| Item | Value |
|---|---|
| WinCC version | SIMATIC WinCC V6.2 SP2 |
| Target runtime | PDLRuntimeSystem (Graphics Runtime / GSC) |
| Trigger | Mouse-click on Button9
|
| Function name observed | @a85 |
| Picture path | @SCREEN.@WIN13:@BUTTONS11 |
| Target tag attempted | inButton9 |
| External process invoked | C:\Program Files\SIEMENS\PLCSIM\s7wsi\s7wsvapx.exe |
| Cycle | acycle (event-triggered, not cyclic) |
| Thread | 5364 (single GUI worker) |
Symptom: OnErrorExecute Diagnostic Frames
Two frames are emitted in the order shown. WinCC runtime always dumps both the configuration fault and the runtime exception so engineers can correlate a bad tag with the downstream crash that it produced.
Frame 1 — dwErrorCode1 1007006
====================================OnErrorExecute====================================
SystemTime: (ThreadId 5364) 2009-07-17 10:26:04.453
dwErrorCode1: (ThreadId 5364) 1007006
dwErrorCode2: (ThreadId 5364) 0
szErrorText: (ThreadId 5364) Tag unknown, timeout or conversion failed
szApplicationName: (ThreadId 5364) PDLRuntimeSystem
bCycle: (ThreadId 5364) acycle
szFunctionName: (ThreadId 5364) @a85
szTagName: (ThreadId 5364) "inButton9"
dwCycle: (ThreadId 5364) 0
szErrorTextTagName: (ThreadId 5364) Tag not exist
lpszPictureName: (ThreadId 5364) @SCREEN.@WIN13:@BUTTONS11
lpszObjectName: (ThreadId 5364) Button9
lpszPropertyName: (ThreadId 5364) (NULL)
dwParamSize: (ThreadId 5364) 24
====================================OnErrorExecute====================================
Frame 2 — dwErrorCode1 1007001, dwErrorCode2 4100
====================================OnErrorExecute====================================
SystemTime: (ThreadId 5364) 2009-07-17 10:26:04.484
dwErrorCode1: (ThreadId 5364) 1007001
dwErrorCode2: (ThreadId 5364) 4100
szErrorText: (ThreadId 5364) Exception in Action
szErrorTextException: (ThreadId 5364) access violation
szApplicationName: (ThreadId 5364) PDLRuntimeSystem
bCycle: (ThreadId 5364) acycle
szFunctionName: (ThreadId 5364) @a85
lpszPictureName: (ThreadId 5364) @SCREEN.@WIN13:@BUTTONS11
lpszObjectName: (ThreadId 5364) Button9
lpszPropertyName: (ThreadId 5364) (NULL)
dwParamSize: (ThreadId 5364) 24
====================================OnErrorExecute====================================
The two frames fire 31 ms apart (10:26:04.453 → 10:26:04.484). The first one is a pure tag-resolution rejection; the second is the unhandled exception generated when the C runtime tries to consume the rejected tag value and continues into external code.
Root Cause Analysis
Two independent faults combine to abort the click handler. They must be fixed in the order shown because the second fault is triggered by the first.
Fault A — Tag "inButton9" Does Not Exist in WinCC Tag Management
The action contains the call:
wVal = GetTagWord("inButton9");
Inside the WinCC tag manager (the Tag Management editor of the WinCC Explorer project, which must be opened to declare internal tags such as inButton9), no variable with that name exists. szErrorTextTagName: Tag not exist is the unambiguous confirmation. WinCC therefore fires dwErrorCode1 = 1007006 ("Tag unknown, timeout or conversion failed"), the action returns without populating wVal, and the runtime continues executing the next statement. The relevance for code interpretation is:
-
1007006 covers three semantics in a single code — tag missing in the configuration database, tag not reachable on its configured channel / connection (timeout, common for S7 protocol tags when the PLC is offline), or a type conversion mismatch between the requested API (
GetTagWord) and the configured tag data type. -
dwErrorCode2 = 0in this trace indicates the failure is configuration-side (tag not exist) rather than transport-side (timeout / CP down). A timeout would pushdwErrorCode2to a non-zero value or the timeout sub-error string. - The error is raised on the acycle event branch, which confirms the trigger is the mouse-click event and not a scheduled refresh.
Unsigned 16-bit to match the GetTagWord API request; otherwise WinCC returns 1007006 even when the name is registered.Fault B — Access Violation in Function @a85
After the tag read returned an unknown status, the runtime continues into startSimulation(bsystemRunning, EndTime). The second OnErrorExecute frame reports:
- dwErrorCode1 = 1007001 → "Exception in Action"
- dwErrorCode2 = 4100 (decimal), i.e. 0x1004
- szErrorTextException = access violation
The C runtime (PDLRuntimeSystem is the GSC = Graphics Subsystem C-runtime) raises WinCC error 1007001 when an action triggers an unhandled structured exception. Sub-code 0x1004 signals an EXCEPTION_ACCESS_VIOLATION (Windows SEH code 0xC0000005, status 4) — the runtime attempted to dereference memory that the process is not permitted to access. Most common causes inside WinCC C-Actions are:
- An uninitialized
WORDreturn value that is later passed by reference into a runtime API expecting aBYTE*/DWORD*/char*pointer. - A function pointer (
startSimulation) called through a prototype whose return type is not__stdcall, causing stack-frame corruption visible as a deferred access violation inside the called function. - A DLL containing the function is loaded with mismatched calling convention (C vs. stdcall) so the address pushed into
startSimulationlands on invalid memory after the first prologue instruction. - Calling code inside a trigger (acycle event) that the C runtime considers unsafe, which sometimes results in a non-deterministic memory fault reported as access violation.
startSimulation() were 100% correct, the 1007006 fault on the preceding statement would still abort the handler because wVal is never written. Always repair the tag fault first; the access violation often disappears once the early GetTagWord succeeds.Why szFunctionName Shows @a85 and Not the Real Function
WinCC synthesizes a pseudo-name of the form @a<nn> for actions whose source header does not name a function entry point that the runtime can match. Several documented conditions produce this name:
- The
apdefap.hfile referenced by the picture does not contain the expected prototype of the action handler, or the picture is reloaded after a header edit that did not propagate. - The project was recompiled by deleting / rebuilding
*.pasand*.a66files without regenerating the function table. - The script's function name (defined in project functions or in a header) collides with another action so the runtime cannot reconcile symbol ownership.
- The script's source code was edited directly outside the Graphics Designer and the new binary was not registered.
For standard event handlers (mouse click, value change, etc.) the runtime normally logs the entry name (OnClick, OnLButtonDown, etc.). The presence of @a85 instead of the expected function indicates that the click action body has lost its function identification through one of the four causes above. The poster observes that @a85 does not appear against any GSC Runtime action ID — that is the symptom of the same compilation-bind failure.
WinCC Error Code Reference
The mapping in the table below is the interpretation set published for WinCC configuration errors. See the official Siemens Support document "How do you evaluate and remedy 'OnErrorExecute'-type configuration errors?" for the full interpretation matrix.
| dwErrorCode1 | dwErrorCode2 | szErrorText | Interpretation |
|---|---|---|---|
| 1007006 | 0 | Tag unknown, timeout or conversion failed | Action requested a tag that is not registered, not reachable, or had an incompatible type |
| 1007001 | 0x1004 (decimal 4100) | Exception in Action | Access violation (EXCEPTION_ACCESS_VIOLATION) inside a C-Action |
| 1007004 | — | Function not found | Referenced project function does not exist or was not compiled |
| 1007005 | — | Function is invalid (parameter or address error) | Parameters to a runtime API do not match expected types |
| 1007012 | — | Picture cannot be loaded | Tag-prefixed picture path is missing or screen change attempted during compile |
| 1007035 | — | No connection to partner (CP) | Channel / CP not active when PLC tag was queried |
Resolution Procedure
Apply the four steps below in order. They collectively repair the missing tag, restore the correct function binding, and harden startSimulation() so the runtime can safely launch PLCSim.
Step 1 — Declare and Synchronize the Tag
- Open the WinCC Explorer and select Tag Management on the project.
- Right-click Internal Tags and choose New Tag….
- Name the tag exactly
inButton9(case-sensitive — WinCC tag names follow SIMATIC identifier rules: 32-char max, start with letter or underscore, no spaces, no special characters other than_). - Set the data type to Unsigned 16-bit (Word). This matches
GetTagWordso no implicit conversion error is generated. - Click Apply, close the editor.
- In the Graphics Designer, open the picture
@BUTTONS11, selectButton9, right-click and choose Properties → Events → Mouse → Click. - Re-attach the C-Action by re-opening the script in the editor and clicking Compile / OK. This registers the function with the regenerated header table.
Step 2 — Verify Tag Type Matching
For the API family used in the script, the data types must align as follows:
| WinCC C-API call | Required Tag Manager data type | C return value |
|---|---|---|
GetTagBit |
Binary Tag | BOOL |
GetTagByte |
Signed / Unsigned 8-bit |
BYTE / char
|
GetTagWord |
Unsigned 16-bit | WORD |
GetTagSWord |
Signed 16-bit | short |
GetTagDWord |
Unsigned 32-bit | DWORD |
GetTagSDWord |
Signed 32-bit | long |
GetTagFloat |
Floating-point 32-bit IEEE | float |
GetTagDouble |
Floating-point 64-bit IEEE | double |
GetTagString |
Text Tag (8-bit / 16-bit) |
char* / buffer |
If inButton9 were created as a Binary Tag, WinCC would still reject the request with 1007006 ("conversion failed").
Step 3 — Repair the @a85 Function Identification
- Close the Graphics Designer on the engineering station.
- Open Windows Explorer and navigate to the project folder (e.g.
\<Server>\WinCCProj\<Project>\GraCS\). - Delete the generated files for the affected picture:
@BUTTONS11.pdl, the matching.a66, and any@BUTTONS11.@@apdefap.*or compiled.fctartefacts. - Re-open the project in the Graphics Designer. The picture regeneration will rebuild the header tables and re-attach the C-Action with its named handler (
OnClick) instead of the synthetic@a85. - Recompile the entire project from the menu Project → Compiler → Graphics.
- Re-test the click event from runtime.
szFunctionNamemust now report the correct function (or your project function name) and not@a85.
Step 4 — Implement PLCSim Launch via ProgramExecute
The recommended way to launch the S7-PLCSIM executable from a WinCC C-Action is ProgramExecute(). The path string must use double-backslashes because Windows C runtime interprets a single \ as the start of an escape sequence.
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
WORD wVal = 0;
DWORD dwRet = 0;
/* --- read the diagnostic tag first to clear the 1007006 fault --- */
wVal = GetTagWord("inButton9");
printf("PLCSim launch initiated from picture %s, button %s\\n",
lpszPictureName, lpszObjectName);
/* --- launch PLCSim non-blocking so the runtime is not stalled --- */
dwRet = ProgramExecute("C:\\Program Files\\Siemens\\Automation\\PLCSIM\\s7wsi\\s7wsvapx.exe");
if (dwRet == 0)
{
printf("ProgramExecute failed, code %u\\n", GetLastError());
}
}
Implementation notes:
-
ProgramExecutereturns 0 on failure or a non-zero code on success; always check the return value. - WinCC 6.2 paired with S7-PLCSIM V5.4 → install path
SIEMENS\PLCSIM. WinCC 7.x with newer PLCSIM versions typically installs toSiemens\Automation\PLCSIM. - Prefer
ProgramExecuteoverWinExec,ShellExecute, orCreateProcess; only WinCC's own API knows the project context and logs the launch through the runtime diagnostics. - Use
ShellExecuteonly if you need to wait for the PLCSim window before continuing (passnShowCmd = SW_SHOWNORMAL); synchronous waits in C-Actions will block the GSC thread and may stall pictures.
Step 5 — Validate startSimulation() Body
When an access violation persists after Steps 1–4, the external startSimulation() itself is at fault. Validate the prototype declaration in the header included by apdefap.h:
/* In the project header (e.g. simulation.h) */
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) long __stdcall startSimulation(int bSystemRunning, double EndTime);
#ifdef __cplusplus
}
#endif
Key invariants:
- The DLL must export with
__declspec(dllexport)and__stdcallon Windows; WinCC resolves symbols with__stdcallconvention on the standard WinCC build target. Mismatched calling conventions are the single most frequent root cause of deferred access violations in@a85-style faults. - All out-parameters must be supplied by the caller; never pass
NULLas the buffer for a return-by-pointer argument. - If the function ultimately calls a third-party API that allocates on the heap (e.g.
CoCreateInstance,malloc,new), initialize COM withCoInitializeEx(NULL, COINIT_APARTMENTTHREADED)per thread — failure to do so produces an access violation deep insideOle32.dllrather than in your code. - Bound the lifetime of stack-resident
char*buffers insidestartSimulationif your call may run during a Stop Runtime / Restart sequence.
Verification
Confirm the fix with all four checks below. Each maps directly to one of the failure modes described above.
-
GSC Runtime window: No new
OnErrorExecuteentries forButton9appear after the click. Log is clean in WinCC Explorer → Tools → GSC Runtime. -
Diagnostic output: The text
PLCSim launch initiated from picture @SCREEN.@WIN13:@BUTTONS11, button Button9is printed exactly once per click, confirmingOnClick(not@a85) executed. - PLCSim window: The S7-PLCSIM UI appears within ~1 s of click and the target AS can be brought online.
-
Tag state:
GetTagWord("inButton9")returns aWORD; setting the tag in Tag Management before the click changes the read value as expected.
Access Violation Diagnostics in PDLRuntimeSystem
When 1007001 persists after the obvious tag and function fixes, instrument the C-Action to localize the fault:
#include "apdefap.h"
#include <stdio.h>
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
printf("[OnClick] entry\\n");
fflush(stdout);
WORD wVal = GetTagWord("inButton9");
printf("[OnClick] tag read: %u\\n", (unsigned)wVal);
fflush(stdout);
/* --- defensive test of startSimulation via function pointer --- */
HMODULE hMod = LoadLibrary("MySimDLL.dll");
if (!hMod) {
printf("[OnClick] LoadLibrary failed: %lu\\n", GetLastError());
return;
}
typedef long (__stdcall *START_SIM_PTR)(int, double);
START_SIM_PTR fnStart = (START_SIM_PTR)GetProcAddress(hMod, "startSimulation");
if (!fnStart) {
printf("[OnClick] startSimulation not exported\\n");
FreeLibrary(hMod);
return;
}
long rc = fnStart(1, 100000.0);
printf("[OnClick] startSimulation returned %ld\\n", rc);
FreeLibrary(hMod);
}
The printf / fflush(stdout) pair is mandatory inside WinCC C-Actions because the GSC redirects stdout only when the buffer is flushed. Without an explicit flush the trace will not appear in the GSC Runtime window. The next printf that prints is the line just before the offending statement.
Action Identification Convention (@<letter><nn>)
| Symbol pattern | Meaning |
|---|---|
@a<nn> |
Generic C-Action whose declared function name could not be resolved (most common cause: missing/edited apdefap.h or orphaned .a66/.pas files) |
@b<nn> |
VBS-Action counterpart (no recompile, but same header-bind failure) |
OnClick, OnLButtonDown, etc. |
Properly bound standard event handlers |
custom_function_name |
Properly bound project / library function |
Any @a or @b pattern is a defect indicator: the picture's C/VBS header table is out of sync with the picture file. Cycling the picture through Steps 3 above clears it.
PLCSim Launch Paths by WinCC / PLCSIM Version
| WinCC release | PLCSIM version | Default install path | Executable |
|---|---|---|---|
| V6.2 / V6.2 SP2 | S7-PLCSIM V5.4 | C:\Program Files\SIEMENS\PLCSIM\s7wsi\ |
s7wsvapx.exe |
| V7.0 / V7.0 SP1 | S7-PLCSIM V5.4 + SP | C:\Program Files\Siemens\Automation\PLCSIM\s7wsi\ |
s7wsvapx.exe |
| V7.2 / V7.3 | S7-PLCSIM V5.4 SP5+ | C:\Program Files\Siemens\Automation\PLCSIM\s7wsi\ |
s7wsvapx.exe |
| V7.4 / V7.5 | PLCSIM Advanced ≥ V2.0 | C:\Program Files\Siemens\Automation\PLCSimAdvanced\ |
S7-PLCSIM.exe |
s7wsvapx.exe for ProgramExecute(). To launch it from a WinCC action, use ShellExecute(NULL, "open", "C:\Program Files\Siemens\Automation\PLCSimAdvanced\S7-PLCSIM.exe", NULL, NULL, SW_SHOWNORMAL) instead. If you target both PLCSIM V5.x and PLCSIM Advanced, branch on the presence of s7wsvapx.exe using GetFileAttributes().Troubleshooting Matrix
| Symptom | Likely cause | Diagnostic | Fix |
|---|---|---|---|
| 1007006 + szTagName populated | Tag missing in Tag Management | Open Tag Management, search tag | Create tag with exact name and matching data type |
| 1007006 + szTagName empty | Type conversion failure only | Compare tag data type vs. GetTag* function | Change API call or tag type |
| 1007006 + dwErrorCode2 ≠ 0 | Timeout / CP unreachable | Check WinCC Channel Diagnosis, CP online status | Establish connection or switch to internal tag |
| 1007001 + access violation | DLL/Calling-convention mismatch or NULL pointer deref | Check export of function, stdcall vs cdecl, NULL arguments | Match prototype to WinCC calling convention, validate pointers |
| szFunctionName starts with @ | apdefap.h out of sync | Open Graphics Designer, regenerate picture | Delete .a66 / .pas / .fct, regenerate picture, recompile |
| Function never visible in GSC Runtime | Action body attached to wrong event or empty | Re-open action, confirm code body is non-empty | Re-author action; do not paste empty scripts |
| ProgramExecute returns immediately, no PLCSim window | Path double-back-slashes error or wrong file version | Inspect path, check PLCSIM install dir | Use double-back-slashes, point at the correct exe |
| PLCSim launches but WinCC picture freezes | Synchronous wait inside action (ShellExecute) | Reduce wait time or use async launch | Use ProgramExecute or fire-and-forget ShellExecute |
Prevention Checklist
- Declare every tag in Tag Management before referencing it from any C/VBS action; never invent tags inside the action editor for testing without also creating them.
- Match each
GetTag*call to the registered data type using the table above; mismatch always produces 1007006. - Keep all function prototypes in dedicated headers included by
apdefap.h; declare DLL exports with__stdcallfor WinCC compatibility. - Avoid re-pasting scripts outside the Graphics Designer; any text-edited file loses the binary header table and the @a<nn> pseudo-name appears.
- Always check the return code of
ProgramExecute()and log it throughprintf+fflush. - Run a project-wide Rebuild all after upgrading the C compiler or replacing a referenced DLL.
- For PLCSIM Advanced targets, branch the launch path (as shown in the table above) and use
ShellExecuteinstead ofProgramExecute.
FAQ
What does WinCC error 1007006 mean?
It indicates that a C-Action attempted to read a tag using the GetTag* API family and the tag is not registered in the WinCC Tag Management, is unreachable through its configured channel (timeout), or has a data type that cannot be converted to the requested type. szErrorTextTagName: Tag not exist confirms a missing tag.
What does WinCC error 1007001 with sub-code 4100 mean?
It indicates a structured exception (unhandled crash) inside the C-Action. dwErrorCode2 = 0x1004 maps to Windows EXCEPTION_ACCESS_VIOLATION. The most common causes inside WinCC C-Actions are NULL pointer dereferences, mismatched calling conventions between the C-Action and a called DLL function, or stale binary references after a recompile.
Why does my click action show szFunctionName "@a85" instead of "OnClick"?
The @a<nn> name is the runtime's pseudo-identifier for any C-Action whose function bind cannot be resolved against apdefap.h. Causes include regenerating the picture without the source header, editing the action outside the Graphics Designer, or having deleted / orphaned .a66 / .pas / .fct artefacts. Delete the generated picture files and re-open the project; the function name will be restored.
How do I start PLCSim from a WinCC button click?
Use ProgramExecute("C:\\Program Files\\SIEMENS\\PLCSIM\\s7wsi\\s7wsvapx.exe") inside the C-Action with double-back-slashes. For PLCSIM Advanced, replace the call with ShellExecute(NULL, "open", "C:\\Program Files\\Siemens\\Automation\\PLCSimAdvanced\\S7-PLCSIM.exe", NULL, NULL, SW_SHOWNORMAL).
Why doesn't my printf output show up in the GSC Runtime window?
WinCC redirects stdout to the GSC Runtime window, but only when the buffer is flushed. Use printf("text\\n"); fflush(stdout); after every message to guarantee the line is captured for diagnostics.
Why does WinCC keep emitting 1007006 even after I created the tag?
The runtime database is built at project compile/startup time. After editing Tag Management you must restart the WinCC Runtime (or perform a controlled RT down → RT up) so the running process reloads the configuration. The Graphics Designer alone is not enough — only RT reload picks up new tags.
Where can I look up a full list of OnErrorExecute error codes?
Refer to the official Siemens Support document "How do you evaluate and remedy 'OnErrorExecute'-type configuration errors?" for the canonical interpretation of configuration errors raised by PDLRuntimeSystem.