04-17-2013 09:50 AM
This is a known issue...
"A System.TypeLoadException
is thrown when the WPF Graph control's DataSource
property is assigned an unknown type.
The set of types supported by the Graph control is extensible. When a data type is encountered for the first time, the Graph control performs a search to determine the best descriptor to use. To determine if the type can be supported, the Graph control constructs the type, but this may generate a System.TypeLoadException
. The exception is handled by the control and is does not reach the user code. The type search result is cached so that an exception is not thrown each time.
Workaround: Disable the System.TypeLoadExpection Thrown option in the Visual Studio Exceptions dialog."
Note the workaround. How do I disable this specific exception? In the Debug->Exceptions dialog, this exception is not checked (meaning the
app shouldnt break).
Any idea how soon a service pack will be released?
I've been looking forward to using measurement Studio with WPF.
Disappointing so far.
04-17-2013 03:01 PM
The workaround is referring to the Exceptions dialog, reached via the Debug » Exceptions... menu in Visual Studio:
When the Thrown box is unchecked, the debugger will not pause execution when that exception is encountered and handled. (When the box is checked, the debugger will pause, but you can use F5 to continue execution as normal and allow the exception to be handled.)
Regarding a service pack, I do not have information on the timing of the next Measurement Studio release, but I do know this issue is targeted for a fix in the next version.
04-18-2013 06:24 AM
Thanks for the reply.
The thrown box is unchecked but it still pauses.
At this point it doesn't really matter. I can't do this in production code.
I'll stick with Winforms until the service pack/next release is available.
04-18-2013 09:22 AM
Are you certain you are encountering the same issue described above? If the debugger is still pausing when the box is unchecked, then it may be a new issue raising an unhandled exception in a different part of the code.
Would you mind posting a code snippet so that I can try to reproduce the issue?
04-18-2013 10:08 AM
Yes, I'm sure.
The samples that shipped Measurement Studio throw the same error.
(Samples\DotNet\WPF\Standard\XYPlotting)
This is a function from the NI samples.
public void OnPlotCircleButtonClick(object sender, RoutedEventArgs e) { const int numberOfPoints = 100; const int radius = 10; const double angleIncrementFactor = TwoPi / (numberOfPoints - 1); double[] dataX = new double[numberOfPoints]; double[] dataY = new double[numberOfPoints]; Point[] dataXY = new Point[numberOfPoints]; double angle = 0; for (int i = 0; i < numberOfPoints; ++i) { angle += angleIncrementFactor; dataX[i] = radius * Math.Cos(angle); dataY[i] = radius * Math.Sin(angle); dataXY[i] = new Point(dataX[i], dataY[i]); } xGraph.DataSource = dataX; yGraph.DataSource = dataY; xyGraph.DataSource = dataXY; // Exception thrown here (assigning array of Points as datasource. }
04-18-2013 01:55 PM
Running the XYPlotting example in Visual Studio 2012, it does look like this matches the known issue (though it occurred in InitializeGraph
when I ran the example). After continuing execution, all of the graphs work as expected for the various "Plot ___" buttons; no further exceptions are raised.
Previously you mentioned that you "can't do this in production code". Since the one-time exception described in the known issue is only visible during interactive debugging and does not effect normal execution, I am not sure what "this" you are referring to. Is there another issue, or is it just the debugging inconvenience that is the problem?
04-22-2013 06:30 AM
Actually I didn't run it ourside of the debugger. If it doesn't occur then its a nonissue.
04-22-2013 09:05 AM
Yes, the exception is raised, but it is handled before it ever reaches user-level code. The only reason you see it in Visual Studio is because the debugger pauses immediately, before any handling code is run. Outside of the debugger, the issue is not visible.
04-22-2013 09:07 AM
Its funny... I installed it on a second PC and the exception isnt raised at all.
I wonder what the difference between the two is.
08-11-2015 11:07 AM
Just wanted to let you know this issue was fixed in the Measurement Studio 2015 release.