I have a large solution, a portion of which is created using a WPF project. In that WPF project is a module in which we create a ViewModel to display all of the styles in a drawing. This has worked flawlessly for the last 5+ years. I am now attempting, again, to add the Pressure Networks styles. The Parts added fine, the label styles for parts, however, are throwing the following error: Get Count failed. Here's an image taken during Debugging when it gets to the Fitting Label styles:
I believe that it successfully has already accessed the Appurtenance label styles at this point, as I call them in succession. The crazy thing is, the following sample works correctly in it's own project:
[CommandMethod("PipeStylesTest")] public void pipestylestest() { var appRoot = CivilApplication.ActiveDocument.Styles.LabelStyles.GetPressureAppurtenanceLabelStyles(); var fitRoot = CivilApplication.ActiveDocument.Styles.LabelStyles.GetPressureFittingLabelStyles(); var pipeRoot = CivilApplication.ActiveDocument.Styles.LabelStyles.GetPressurePipeLabelStyles(); testit(appRoot.LabelStyles); testit(fitRoot.LabelStyles); testit(pipeRoot.LabelStyles); } private void testit (LabelStyleCollection styles) { foreach (AcDb.ObjectId id in styles) { LabelStyle style = (LabelStyle)id.Open(AcDb.OpenMode.ForRead); style.Close(); } }
This nearly identical to how the code in the WPF project is written. Any ideas as to why this would work in the small example, but fail everytime in the WPF project would be greatly appreciated.
Solved! Go to Solution.
Solved by augusto.goncalves. Go to Solution.
For this case, please don’t take LabelStylesRoot as a input parameter.