Error reading excel file on ubuntu 18.04 using EPPlus - epplus

I using EPPlus with ASP.NET Core 2 to read excel template file and fill with data from database and send result file to client.All work well on development machine running windows but when publish to ubuntu server it got error when reading excel file
This is exception
XPathException: ':calcPr' has an invalid token.
This is stack trace
MS.Internal.Xml.XPath.XPathScanner.NextLex()
MS.Internal.Xml.XPath.XPathScanner..ctor(string xpathExpr)
MS.Internal.Xml.XPath.XPathParser.ParseXPathExpression(string xpathExpression)
System.Xml.XPath.XPathExpression.Compile(string xpath, IXmlNamespaceResolver nsResolver)
System.Xml.XPath.XPathNavigator.Compile(string xpath)
System.Xml.XmlNode.SelectSingleNode(string xpath, XmlNamespaceManager nsmgr)
OfficeOpenXml.XmlHelper.CreateNode(string path, bool insertFirst, bool addNew)
OfficeOpenXml.XmlHelper.SetXmlNodeString(XmlNode node, string path, string value, bool removeIfBlank, bool insertFirst)
OfficeOpenXml.ExcelWorkbook..ctor(ExcelPackage package, XmlNamespaceManager namespaceManager)
OfficeOpenXml.ExcelPackage.get_Workbook()
VINPSP.Controllers.ReportController.GetExcelWorkBook2(string id) in E:\Work\Office\Project\VINPSP\VINPSP\Controllers\ReportController.cs

Related

I'm trying to set up a new SharePoint production server and getting an error creating an Open XML 2.5 document

I have a SharePoint application written in Visual Basic that works fine and creates Word Documents using Open XML 2.5 on my development machine. We recently set up a new Production server and I published the .wsp file and deployed it on the new server. The application all works fine except the code that generates reports in Word format. It fails on the following line of code.
Dim wpd As WordprocessingDocument = WordprocessingDocument.Create(MemStream, WordprocessingDocumentType.Document, True)
This is what the code looks like in the function that is failing.
''' \<summary\>
'''
''' \</summary\>
''' \<param name="MemStream"\>\</param\>
''' \<returns\>\</returns\>
Public Function WPDCreateFromStream(MemStream As MemoryStream) As WordprocessingDocument
Try
Dim wpd As WordprocessingDocument = WordprocessingDocument.Create(MemStream, WordprocessingDocumentType.Document, True)
Dim MainPart As MainDocumentPart = wpd.AddMainDocumentPart()
MainPart.Document = New Document()
Dim DocBody As New Body()
Return wpd
Catch ex As Exception
WriteErrorToEventLog("OpenXML", "WPDCreateFromStream", "", ex)
Return Nothing
End Try
End Function
Here is the exception detail I get when trying to make the WordProcessingDocument.Create call above.
ERROR: Source: OpenXML Routine: WPDCreateFromStream User:
Message: The type initializer for 'MS.Utility.EventTrace' threw an exception.
StackTrace: at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateCore(Stream stream)
at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(Stream stream, WordprocessingDocumentType type, Boolean autoSave)
at FIS.SP.PSTARProjectTracker.PSTAR.Core.BusinessLogic.OpenXML.WPDCreateFromStream(MemoryStream MemStream)
Source: WindowsBase
Data: System.Collections.ListDictionaryInternal
InnerException: System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at Microsoft.Win32.Registry.GetValue(String keyName, String valueName, Object defaultValue)
at MS.Utility.EventTrace.IsClassicETWRegistryEnabled()
at MS.Utility.EventTrace..cctor()
The Zone of the assembly that failed was:
MyComputer
ToString: System.TypeInitializationException: The type initializer for 'MS.Utility.EventTrace' threw an exception. ---> System.Security.SecurityException: Requested registry access is not allowed.
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at Microsoft.Win32.Registry.GetValue(String keyName, String valueName, Object defaultValue)
at MS.Utility.EventTrace.IsClassicETWRegistryEnabled()
at MS.Utility.EventTrace..cctor()
--- End of inner exception stack trace ---
at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateCore(Stream stream)
at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Create(Stream stream, WordprocessingDocumentType type, Boolean autoSave)
at FIS.SP.PSTARProjectTracker.PSTAR.Core.BusinessLogic.OpenXML.WPDCreateFromStream(MemoryStream MemStream)
TargetSite: Void EasyTraceEvent(Keyword, Event)
I know this is not an issue with the code as the same code works in development. I assume it has to do with permissions, or getting the DocumentFormat.OpenXML.dll installed / registered correctly on the new server, but I've had no luck searching for a solution.
I tried installing OpenXML and the Productivity tool on the server. The productivity tool works and can open a word document, but the Application has the same issue.
If anyone has run into this and can point me to a solution, I would appreciate it.
The MemoryStream is created and passed in to be used by this function. The WordProcessingDocument is returned to the calling function. I could explicitly call ByVal, but in this case it would not change anything.
I am creating a new document, that is why it is coded using WordProcessingDocument.Create
Remember, this code all functions perfectly on the development SharePoint server. It has been used heavily for about a year. I'm just trying to get this to work on a new production server we recently stood up. I have to believe this is related to some permission issue, or a component that is not installed or registered correctly. For Open XML, I believe there is just the one DLL (DocumentFormat.OpenXML.DLL) and it does not register. It is on the server from installing the .wsp package. I also tried installing Open XML 2.5 on the server along with the productivity tool and they all work fine.
The more I think about it, it just feels like a permission issue.

Unable to in install Pdftron Virtual Printer

In my ASP .Net application, I am using 'PDFTron 6.0.1.0'.
Prior converting my docx files to xod(using pdftron.PDF.Convert.ToXod method), we are checking the presence of virtual printer, and install it if not present. For this we are using following code:
private void CheckIfVirtualPrinterRequired(string inputFilePath, out bool uninstallVirtualPrinter)
{
uninstallVirtualPrinter = false;
if (pdftron.PDF.Convert.RequiresPrinter(inputFilePath))
{
if (pdftron.PDF.Convert.Printer.IsInstalled("PDFTron Creator"))
{
pdftron.PDF.Convert.Printer.SetPrinterName("PDFTron Creator");
}
else if (!pdftron.PDF.Convert.Printer.IsInstalled())
{
pdftron.PDF.Convert.Printer.Install();
uninstallVirtualPrinter = true;
}
}
}
However, at 'pdftron.PDF.Convert.Printer.Install();' code, I am getting SEHException:
External component has thrown an exception. Stack Trace: at
trn.PDF.Convert.Printer.Install(UString* ) at
pdftron.PDF.Convert.Printer.Install() at
*****.PDFTronService.CheckIfVirtualPrinterRequired(String inputFilePath, Boolean& uninstallVirtualPrinter) in
c:***\PDFTronService.cs:line 126
I have tried after manually installing 64-bit versions of 'PDFTron Creator' and 'PDFTron PDFNet' printers, but the conversion still fails with error:
Unable to convert file, too many attempts. Conditional expression:
false, Filename : Convert.cpp, Function :
trn::PDF::Convert::ToPdf, Linenumber : 1742 at
pdftron.PDF.Convert.ToXod(inputFilePath, outFileName);
Please help with this issue.
First, the virtual printer is not actually required for Office conversion, if you have MS Office installed. If MS Office is installed, PDFNet will use Interop to communicate. RequiresPrinter returns true for office documents, though it is really optional for office documents.
The virtual printer is typically used for other file types, e.g. AutoCad DWG.
If you don't have MS office installed, and want to convert office documents using something like LibreOffice, then yes you would need the virtual printer.
Also, you only need to install the printer once. Not every time you want to convert.
To install the virtual printer, you need to be running with elevated rights, and PDFNet 32bit|64bit needs to match your OS 32bit|64bit.
If the SEH error persists, then I would recommend trying the latest version of PDFNet.

Using Kentico API from LINQPad is throwing an exception

I am trying to call Kentico API from LINQPad, but getting the following exception:
[AbstractProvider.GetProvider]: The object type 'cms.document' is missing the provider type configuration
My code is:
void Main()
{
var pages = DocumentHelper.GetDocuments("CMS.MenuItem").Path("/", PathTypeEnum.Children);
pages.Dump();
}
Note: I tested the code from Visual Studio, it works, but not from LINQPad.
The problem is that during the initial discovery Kentico looks only at the following paths:
AppDomain.CurrentDomain.BaseDirectory
AppDomain.CurrentDomain.RelativeSearchPath
Which in case of LINQPad are C:\Program Files (x86)\LINQPad4\ and null. Therefore the providers do not get resolved.
I've tried running the code in a new AppDomain but it doesn't seem to work in LINQPad. I suggest submitting this to Kentico as an idea or an issue.
A workaround to this would be copying the LINQPad executable to a location of Kentico DLLs - e.g. C:\inetpub\wwwroot\Kentico82\Lib. That works just fine.
Update (thx to Joe Albahari):
If you wrap your code in this:
var appDomain = Util.CreateAppDomain ("AD", null, new AppDomainSetup
{
PrivateBinPath = #"C:\inetpub\wwwroot\Kentico82\CMS\bin",
});
appDomain.DoCallBack(() => { /* your code */ });
you'll be able to execute it. However, you can't Dump() it to the output window. But you can write it to a text file for example. If you experience the following error:
FileNotFoundException: Could not load file or assembly 'LINQPad, Version=1.0.0.0, Culture=neutral, PublicKeyToken=21353812cd2a2db5' or one of its dependencies. The system cannot find the file specified.
Go to Edit -> Preferences -> Advanced -> Run each query in its own process and turn it off.

Issue with SQL Server FileStream

We are currently reviewing an issue we have on one of our live environments where OpenFileStream (private method inside SqlFileStream C# class)
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the path specified at System.Data.SqlTypes.SqlFileStream.OpenSqlFileStream(String path, Byte[] transactionContext, FileAccess access, FileOptions options, Int64 allocationSize)at System.Data.SqlTypes.SqlFileStream..ctor(String path, Byte[] transactionContext, FileAccess access, FileOptions options, Int64 allocationSize)at System.Data.SqlTypes.SqlFileStream..ctor(String path, Byte[] transactionContext, FileAccess access)
We have this working on another environment with no issues. The code we are using to call is as follows:
using (SqlCommand command = new SqlCommand(insertFileSql, conn, transaction))
{
string path = null;
byte[] context = null;
using (SqlDataReader reader = command.ExecuteReader())
{
reader.Read();
path = reader.GetString(reader.GetOrdinal("PathName"));
fileID = reader.GetGuid(reader.GetOrdinal("FileId"));
context = (byte[])reader[reader.GetOrdinal("Context")];
}
richTextBox1.AppendText(
string.Format("Path: {0}, FileID:{1}, content: {2}", path, fileID, Convert.ToString(context)));
using (SqlFileStream strm = new SqlFileStream(path, context, FileAccess.ReadWrite))
{
// copy the user file to the Filestream
inputFileStream.CopyTo(strm);
}
We've looked at ports/firewalls and even got to the point of seeing it is NtCreateFile failing inside the .Net Source code (with a value of 3221225530) but I can't find documentation on what that value or the value returned form IOStatusBlock which is one of the return parameters.
\\v02-A60EC2F8-2B24-11DF-9CC3-AF2E56D89593\dbFileStore\dbo\tblFile\DataFile\AC50B769-B6F8-43AA-B266-E4E837D78BA0\VolumeHint-HarddiskDmVolumes\\SQLData
Is there anything anybody else could suggest to look at, me and my team have been looking at this for best part of two days.
Cheers,
J
Though so much time has passed, we with SQL Server 2012 had this problem with ReadWrite. No problem with Read, no problem with Write, but only with ReadWrite.
Looks like something happens during install/uninstall of SQL Server updates - a registry setting gets accidently removed by setup. Readding it with .reg file:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\FsctlAllowlist]
"FSCTL_SQL_FILESTREAM_FETCH_OLD_CONTENT"=dword:00092560
Worked out that it was Veritas Storage Foundation which wasn't working with SQL FileStream, seems there is a bit of issue with VSF when performing Windows API calls.

Trouble creating the DNN Survey Module from source code

My boss has asked me to set up DotNetNuke's Survey Module and make a few custom changes to it for a client. But I'm having trouble just getting the bare-bones code to run properly!
Here's what I've done so far:
Downloaded both the source & install folders from
http://dnnsurvey.codeplex.com/releases/view/65186
Created a new VB Web Application Project
Took out all the default pages
Copied the Survey source code into the VB Web Application Project in exactly the same structure
Made a batch script that creates an installation folder identical to DNN's install folder (double-checked by running a folder-diff on it, and all files/folders were identical)
Zipped up my installation folder using 7-zip
The source code compiles perfectly. But even though the files/folders are identical, DNN's zipped package will work properly on my DNN site, and my own zipped package will fail with this famous error message:
Error: Survey is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Could not load type 'DotNetNuke.Modules.Survey.survey'. ---> System.Web.HttpParseException: Could not load type 'DotNetNuke.Modules.Survey.survey'. ---> System.Web.HttpParseException: Could not load type 'DotNetNuke.Modules.Survey.survey'. ---> System.Web.HttpException: Could not load type 'DotNetNuke.Modules.Survey.survey'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
I've already asked about this on the DNN forums, but they don't have much to say about it :( So, I thought I'd try StackOverflow as well.
Does anybody have any idea what the problem could be? Thanks very much in advance!
If you want to create package, correctly, you have to first install the module that you have in your dnn instance. Once you are done with that, you did the right job till step4. After step 4 I generally do following:
Go to project properties, and point the bin directory path to parent dnn installation's bin directory
Add reference of dotentnuke.dll and microsoft data acecss application blogs dll
Rebuild the project
Once you can correctly compile the app, you are ready to customize it.
Always use dnn's module create wizard to create package. it is easier and error free way of packaging and delivering the modules.
let me know if you need any other help
I ended up solving this one on my own. These are the steps I took:
Removed all Namespace DotNetNuke.Modules.Survey declaractions
Deleted the ascx, ascx.vb, and designer files for survey, Settings,
and EditSurvey
Created new, empty ones with those names (but used "Survey" instead
of "survey")
Copied/pasted the ascx code into each ascx file (and changed
DotNetNuke.Modules.survey to DotNetNuke.Modules.Survey)
Did a build
Copied/pasted the ascx.vb code into each ascx.vb file (and removed
the Namespace declarations in these files)
Did a build, which was 100% successful this time
Bizarre way to solve the problem, but it worked. :3