Answered by:
MVC web app error The type initializer for 'MS.Utility.EventTrace' threw an exception. when calling SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(file, SpreadsheetDocumentType.Workbook);

Question
-
User-351932365 posted
have a class inside mvc 6 application calling SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(file, SpreadsheetDocumentType.Workbook);
error is The type initializer for 'MS.Utility.EventTrace' threw an exception when calling SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(file, SpreadsheetDocumentType.Workbook);
I have all the openxml working inside an exe program. Moved the one class over to MVC, Where can I start?
Cindy
Friday, September 25, 2020 12:00 AM
Answers
-
User1686398519 posted
Hi cmellocanon,
- Have you installed DocumentFormat.OpenXml?You can install it through NuGet.
- SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(file, SpreadsheetDocumentType.Workbook);
- Is the value of the file correct?
Best Regards,
YihuiSun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 25, 2020 7:20 AM
All replies
-
User-351932365 posted
also is this a permissions issue from trace? With exe was writing to a share on c. all users have permission. With mvc do I have to write to a folder inside of mvc app?
Application Authentication Tag(arftr) SPApplicationAuthenticationModule.IsBearerChallengeRequested: Return 'False'. Claims Authentication Tag(crpqx) STS setting for SuppressModernAuthForOfficeClients:'True'. 0.002030 0.002030 Application Authentication Tag(bjkut) IsClaimsTrustedAuthenticationOnly: 'False', IsOfficeClientIDCRLRequest: 'False', HasSPTrustedSecurityTokenIssuer: 'False', ForceIdcrlForOfficeClients: 'True'. Friday, September 25, 2020 12:08 AM -
User1686398519 posted
Hi cmellocanon,
- Have you installed DocumentFormat.OpenXml?You can install it through NuGet.
- SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(file, SpreadsheetDocumentType.Workbook);
- Is the value of the file correct?
Best Regards,
YihuiSun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 25, 2020 7:20 AM -
User-351932365 posted
I reinstalled the package, same error. By file, and this part does work in the console app. For example I can run console app and file is created so when code runs it first checks is there an old file then delete it.
System.IO.FileInfo newFile = new System.IO.FileInfo(fileName);
if (File.Exists(fileFullname))
{
newFile.Delete();
};The file is in a share on c that all users have modify
then I run
// Create a spreadsheet document by providing a file name.
SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
Create(file, SpreadsheetDocumentType.Workbook);where file is that same share
and error is the same
{"The type initializer for 'MS.Utility.EventTrace' threw an exception."}
do I have to use a folder inside the mvc app as the location to create? is that a difference between mvc and console app? sorry feel like I am out of my depth....do not have another developer to ask questions
Friday, September 25, 2020 3:04 PM -
User-351932365 posted
Thank you YihuiSun,
The mvc application could not do c fileshare, using folder inside of mvc with map path The code is working.
Cindy
Friday, September 25, 2020 4:21 PM