This project has moved. For the latest updates, please go here.

Compilation Error with .Calculate Method

Aug 26, 2014 at 9:20 AM
Edited Aug 26, 2014 at 11:23 AM
Hi all, is there any way that I can see more specifics on compilation errors using Epplus. If I have a compilation failure, the only error message Visual Studio 2012 displays is
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'The invocation of the constructor on type 'Sizer.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.

If there is a handler for this exception, the program may be safely continued. 
It's not very informative so I end up having to step back through lines of code and comment them out individually so that I can try and find the source of the compilation. If I could see more information, it would help me identify the source of the problem quicker.



As a carry on from the above, I have identified the source of my compilation failure for my current issue. I'm using 4.0 Beta2 and trying to call the .Calculate method. To me the code seems ok but obviously something is up. Any help greatly appreciated.
            count = 15;
            for (rowid = (siu_row + 1); rowid <= (siu_row + count); rowid++)
            {
                XLS_Modules.Cells[rowid, column_total].Formula = "SUM(" + XLS_Modules.Cells[rowid, column_smsc_mo].Address + ":" + XLS_Modules.Cells[rowid, column_total - 1].Address + ")";
                XLS_Modules.Cells[rowid, column_total].Style.Fill.BackgroundColor.SetColor(Color.Yellow);
                XLS_Modules.Cells[rowid, column_total].Style.Font.Bold = true;
            }
            XLS_Modules.Cells[rowid, column_total].Formula = "SUM(" + XLS_Modules.Cells[(siu_row + 1), column_total].Address + ":" + XLS_Modules.Cells[(rowid - 1), column_total].Address + ")";

            XLS_Modules.Cells[rowid, column_total].Calculate();
total_capacity_required = Convert.ToInt16(XLS_Modules.Cells[rowid, column_total].Value);
If I comment out XLS_Modules.Cells[rowid, column_total].Calculate(); , then it compiles and works fine. I need to use the Calculate method as I want to assign the calculated value in the cell to total_capacity_required

Any help greatly appreciated.
Thanks
Shav
Aug 26, 2014 at 11:54 AM
I've been doing some more digging and the build seems to be fine. It's Debug that's outputting the message. Here's more info on why Calculate() is failing but not really pointing me in a direction that I can understand/fix.
A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.dll
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'Sizer.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
Thanks
Shav
Aug 26, 2014 at 1:18 PM
I'm some clown. Just spotted that issue is unrelated to this and was due to problem with another part of the code. Lesson learned to put better debugging output into my code. Thanks
Shav
Marked as answer by Shav on 8/26/2014 at 6:18 AM