Hi,
I follow the example in http://help.infragistics.com/NetAdvantage/DV/2010.3/CLR4.0/ in order to import data from Excel in a XamPivotGrid.
My problem is that I get a security exception at line :
ExcelDataConnectionSettings excelDataSettings = new ExcelDataConnectionSettings { FileStream = fileStream, GeneratedTypeName = PivotGridStrings.XPG_ExcelFileDataSource_InitialCube, WorksheetName = PivotGridStrings.XPG_ExcelFileDataSource_WorksheetName };
------------------
The type initializer for 'SR' threw an exception.
Any ideas?
Thank u
D.
Hi Dimitris,
This exception may have been thrown if you are trying to access a non-existent resx file. Is it possible that you copy-pasted the code from the samples, but did not replace the references to our resx files with your own strings?
Regards,
Yes I want to open the file from my local disk. And I open it following the example (dialog Open) :
OpenFileDialog openFileDialog = new OpenFileDialog();
bool? showDialog = openFileDialog.ShowDialog();
if (showDialog == true)
{
Stream stream = openFileDialog.File.OpenRead();
FlatDataSource dataSource = CreateDataSource(stream);
this.pivotGrid.DataSource = dataSource;
this.dataSelector.DataSource = dataSource;
stream.Close();
}
then at ExcelDataConnectionSettings excelDataSettings = new ExcelDataConnectionSettings { FileStream = fileStream, GeneratedTypeName = PivotGridStrings.XPG_ExcelFileDataSource_InitialCube, WorksheetName = PivotGridStrings.XPG_ExcelFileDataSource_WorksheetName };
Name = '((System.IO.FileStream)(fileStream)).Name' threw an exception of type 'System.Security.SecurityException'
Hello, D.
The PivotGridStrings.XPG_ExcelFileDataSource_InitialCube and PivotGridStrings.XPG_ExcelFileDataSource_WorksheetName are string entries in a resx resource file in the SamplesBrowser. If you haven't got a valid resx file with the correct namespace references or the same entries do not exist in it, well, probably this is your problem. Make sure you replace them with the appropriate values or point them to valid resx entries.
All the best,
Atanas
Could it be due to the fact that you are trying to reference an Excel file stored on the file system? If that's the case, you should probably be adding the Excel file you're referencing in the ClientBin folder and update your path in the code accordingly.