Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second instance of download rejected #554

Closed
1 of 2 tasks
AlBakerKY opened this issue Oct 18, 2017 · 4 comments
Closed
1 of 2 tasks

Second instance of download rejected #554

AlBakerKY opened this issue Oct 18, 2017 · 4 comments
Labels

Comments

@AlBakerKY
Copy link

AlBakerKY commented Oct 18, 2017

Testorama (3).xlsx

Read and complete the full issue template

Do you want to request a feature or report a bug?

  • Bug
  • Feature

Version of ClosedXML

0.89

What is the current behavior?

When trying to download the XMLfile it is rejected. Virus scanners claim infection. This same issue is discussed by another user in the following SO post.

https://stackoverflow.com/questions/46515739/asp-net-mvc-5-with-closedxml-not-able-to-export-to-excel-getting-virus-detecti

Also noted this error. Please see the inserted emphasis.....

{"Message":"An error has occurred.","ExceptionMessage":"The type initializer for 'MS.Utility.EventTrace' threw an exception.","ExceptionType":"System.TypeInitializationException","StackTrace":" at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)\r\n at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)\r\n at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.CreateCore(Stream stream)\r\n at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Create(Stream stream, SpreadsheetDocumentType type, Boolean autoSave)\r\n at ClosedXML.Excel.XLWorkbook.CreatePackage(Stream stream, Boolean newStream, SpreadsheetDocumentType spreadsheetDocumentType, SaveOptions options)\r\n at ClosedXML.Excel.XLWorkbook.SaveAs(Stream stream, SaveOptions options)\r\n at HALCommon.Utilities.Reporting.Cba.Render()\r\n at HALTest.Controllers.API.JournalAPIController.ExportAsCba(String id)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()","InnerException":{"$type":"System.Web.Http.HttpError, System.Web.Http","Message":"An error has occurred.","ExceptionMessage":"Requested registry access is not allowed.","ExceptionType":"System.Security.SecurityException","StackTrace":" at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)\r\n at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)\r\n at Microsoft.Win32.Registry.GetValue(String keyName, String valueName, Object defaultValue)\r\n at MS.Utility.EventTrace.IsClassicETWRegistryEnabled()\r\n at MS.Utility.EventTrace..cctor()"}}

What is the expected behavior or new feature?

Not being or matching the pattern of a virus.

Did this work in previous versions of our tool? Which versions?

Unknown

Reproducibility

For our particular installation, it occurs on all exported spreadsheets.

Code to reproduce problem:

 public MemoryStream Render()
        {
            var stream = new MemoryStream();
            CreateDocument().SaveAs(stream);
            return stream;
        }

   using (var stream = new HALCommon.Utilities.Reporting.Cba(journal).Render())
            {
                var result = new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new ByteArrayContent(stream.ToArray())
                };
 
                result.Content.Headers.ContentDisposition =
                    new ContentDispositionHeaderValue("attachment")
                    {
                        FileName = $"{journal.Name}.xlsx"
                    };
                result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                return ResponseMessage(result);
            }
@igitur
Copy link
Member

igitur commented Oct 18, 2017

Complete the full template.

@igitur igitur added the RTFM label Oct 18, 2017
@igitur igitur closed this as completed Nov 9, 2017
@mikaelweave
Copy link

@igitur - Did you ever find a solution??

@igitur
Copy link
Member

igitur commented Feb 2, 2018

No, sorry

@mikaelweave
Copy link

It appears to be related to impersonation in the web.config. Remove that and impersonate only where you need in code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants