Hello,
In a project I’m working on, I’m automating an old VB6 application. The particular sequence I’m working on does the following:
GetAttribute → Retrieve “aastate” attribute from button, store in variable called “aastate” (GenericValue)
MessageBox → "Delete box aastate: " & aastate.ToString → “Delete box aastate: focusable”
While → NOT aastate.ToString.Contains("unavailable")
The first operation inside of the while loop is a message box displaying that we’ve entered the while loop, though this is not hit.
I’ve attached a breakpoint to the while loop and stepped into it. First step is alright, though I’m not sure what this step represents. Stepping in again, I get this message box:
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , ActivityContext )
at Microsoft.VisualBasic.Activities.VisualBasicValue`1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
The NRE exception details are rather sparse, though I’m not particularly certain what’s causing it.
I’ve confirmed that aastate
is not null (see workflow overview) and to take this a step further, I even replicated the condition for the while loop in a text box. You can see the results of that here:
Upon hitting that while loop though, the NRE is thrown. Here is the xml source for that while loop.
<ui:MessageBox Caption="{x:Null}" ChosenButton="{x:Null}" Buttons="Ok" DisplayName="Message Box" sap:VirtualizedContainerService.HintSize="775,59" sap2010:WorkflowViewState.IdRef="MessageBox_11" Text="["Delete box aastate: " & aastate.ToString]" TopMost="True" />
<While sap:VirtualizedContainerService.HintSize="775,759" sap2010:WorkflowViewState.IdRef="While_4">
<While.Variables>
<Variable x:TypeArguments="ui:GenericValue" Name="aastate" />
</While.Variables>
<While.Condition>[NOT aastate.ToString.Contains("unavailable")]</While.Condition>
<!-- Snip -->
</While>
Everything appears to be correct, though if I’ve missed anything, do let me know.
Things I’ve tried:
- Messagebox debugging
- Debug mode inspection
- Adding debug symbol path environment variable
(Credit to Tanner of Microsoft for thinking of this, even if nothing happened as a result.) - Inspected published nuget package to see if there were an exe - Tanner wanted to try
devenv /debugexe <full path to exe>
though unfortunately the nuget package merely contained the project xaml and supporting files.
Additional goodies:
Tanner suggested the following:
Also, at least looking at: Reference Source It looks like the code is “probably” going down
expressionTree.Compile()
and thencompiledExpression(context)
wherecompiledExpression
is the thing with the NRESo, it’s likely something in the LINQ expression tree that has the bug
(which I assume is produced from the XAML)
If there’s anything I missed, do let me know. This is a rather strange issue.
As a work-around, I’ll allocate another variable and store the result of the calculation inside that variable, then pass that variable directly into the while loop. Should this not work for whatever reason, I’ll update this post.