none
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. RRS feed

  • Question

  • Hello,

    I have a macro that opens a file and then it refreshes the query with a file from sharepoint site.

    When I'm stepping through the subroutine everything works fine but when I run it, it gives me an Unexpected Error message. In the details of the error it says: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    My credentials to the sharepoint site are saved so it's not the issue.

    Here's the error message:

    Feedback Type: Frown (Error) Error Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Stack Trace: Server stack trace: at Microsoft.Mashup.Client.Excel.NativeExcelFunctionsC2R.Microsoft.Mashup.Client.Excel.INativeExcelFunctions.GetNamedObjects(IntPtr workbookPointer) at Microsoft.Mashup.Client.Excel.ExcelHost.<>c__DisplayClass4.<TryGetTableNames>b__3() at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass6`1.<SendAndMarshalExceptions>b__5() at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass3.<SendAndMarshalExceptions>b__0(Object null)

    Please help


    Friday, December 14, 2018 2:37 PM

Answers

All replies

  • Hi,

    Can you please submit a Frown next time you encounter this error? It will help us to investigate.

    Guy

    - Excel Team


    Guy Hunkin - Excel Team

    Tuesday, December 18, 2018 9:36 PM
  • I also have an issue and get the same exact stack trace. 

    I have a master workbook that serves as a pseudo DB for other workbooks, we will call it "Main". There are queries inside of each of the sub workbooks, we will call them "Sub1", "Sub2", etc.

    Sub1, Sub2, etc., query tables from Main and use them as tables. These tables are then queried and form another table inside of Sub1, Sub2, etc.

    If any two of these workbooks are open together, Main with Sub1, Sub1 with Sub2, etc. then I get the protected memory error and have to hit Close a bazillion times.

    Attached is some of the error.

    Feedback Type:
    Frown (Error)
    
    Error Message:
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    
    Stack Trace:
    
    Server stack trace: 
       at Microsoft.Mashup.Client.Excel.NativeExcelFunctionsC2R.GetNamedObjects(IntPtr workbookPointer)
       at Microsoft.Mashup.Client.Excel.ExcelHost.<>c__DisplayClass4.<TryGetTableNames>b__3()
       at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass6`1.<SendAndMarshalExceptions>b__5()
       at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.<>c__DisplayClass3.<SendAndMarshalExceptions>b__0(Object null)
    
    Exception rethrown at [0]: 
       at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.SendAndMarshalExceptions(SynchronizationContext context, Action callback)
       at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.SendAndMarshalExceptions[T](SynchronizationContext context, Func`1 callback)
       at Microsoft.Mashup.Client.Excel.ExcelHost.TryGetTableNames(PackageReference packageReference, String[]& tableNames)
       at Microsoft.Mashup.Host.Document.Evaluation.EvaluatorHost.<CreateSession>b__8(PackageReference packageRef)
       at Microsoft.Mashup.Host.Document.Evaluation.ExcelService.TryGetTableNames(String[]& tableNames)
       at Microsoft.Mashup.Host.Document.Evaluation.Services.RemoteExcelServiceFactory.Stub.OnTableNamesRequest(IMessageChannel channel, TableNamesRequestMessage request)
       at Microsoft.Mashup.Evaluator.MessageHandlers.TryDispatch(IMessageChannel channel, Message message)
       at Microsoft.Mashup.Evaluator.ChannelMessenger.ChannelMessageHandlers.TryDispatch(IMessageChannel channel, Message message)
       at Microsoft.Mashup.Evaluator.MessageHandlers.Dispatch(IMessageChannel channel, Message message)
       at Microsoft.Mashup.Evaluator.ChannelMessenger.OnMessageWithUnknownChannel(IMessageChannel baseChannel, MessageWithUnknownChannel messageWithUnknownChannel)
       at Microsoft.Mashup.Evaluator.MessageHandlers.TryDispatch(IMessageChannel channel, Message message)
       at Microsoft.Mashup.Evaluator.ChannelMessenger.ChannelMessageHandlers.TryDispatch(IMessageChannel channel, Message message)
       at Microsoft.Mashup.Evaluator.MessageHandlers.Dispatch(IMessageChannel channel, Message message)
       at Microsoft.Mashup.Evaluator.Interface.IMessageChannelExtensions.WaitFor[T](IMessageChannel channel)
       at Microsoft.Mashup.Evaluator.RemotePreviewValueSource.PreviewValueSource.WaitFor(Func`1 condition, Boolean disposing)
       at Microsoft.Mashup.Evaluator.RemotePreviewValueSource.PreviewValueSource.get_TableSource()
       at Microsoft.Mashup.Evaluator.Interface.TracingPreviewValueSource.get_TableSource()
       at Microsoft.Mashup.Host.Document.Analysis.PackageDocumentAnalysisInfo.PackagePartitionAnalysisInfo.SetPreviewValue(EvaluationResult2`1 result, Func`1 getStaleSince, Func`1 getSampled)
       at Microsoft.Mashup.Host.Document.Analysis.CachingDocumentAnalysisInfo.CachingPartitionAnalysisInfo.SetPreviewValue(EvaluationResult2`1 result, Func`1 getStaleSince, Func`1 getSampled)
       at Microsoft.Mashup.DocumentHost.DocumentAnalyzer.Analyze(IPartitionAnalysisInfo partitionInfo, AccessRecorder recorder, EvaluationResult2`1 result, Action`1 callback)
       at Microsoft.Mashup.DocumentHost.DocumentAnalyzer.<>c__DisplayClass10.<BeginAnalyzeDocumentPartition>b__d(EvaluationResult2`1 result)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation`1.Complete(EvaluationResult2`1 result)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation`1.Complete(EvaluationResult2`1 result)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.DocumentEvaluator.<>c__DisplayClass3`1.<BeginGetResult>b__0(EvaluationResult2`1 result)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose(Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.Interface.EvaluationResultExtensions.InvokeThenOnDispose[T](Action`1 callback, EvaluationResult2`1 result, Action action)
       at Microsoft.Mashup.Evaluator.LimitedDocumentEvaluatorFactory.Evaluation`1.Complete(EvaluationResult2`1 result)
       at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation`1.TryComplete(EvaluationResult2`1 result)
       at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.PreviewValueSourceRemoteEvaluation.GetResult(Boolean enableFirewall)
       at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.RemoteEvaluation.Evaluate(Boolean enableFirewall)
       at Microsoft.Mashup.Evaluator.EvaluatorThreadPool.EvaluatorThread(Object state)
       at Microsoft.Mashup.Evaluator.SafeThread2.<>c__DisplayClass15.<CreateAction>b__14(Object o)
    

    Saturday, January 5, 2019 10:43 PM
  • Hi Foloko,

    I am not sure I fully understand your scenario. Can you please provide step-by-step instructions to help me to reproduce the issue locally?


    Guy Hunkin - Excel Team

    Sunday, January 6, 2019 3:34 PM
  • Sure.

    Create a workbook with tables (Main.xlsm). Create another workbook with queries on those tables (Sub1.xlsm). Create a copy of Sub1.xlsm and rename Sub2.xlsm, Sub3.xlsm, etc. 

    That's the basic gist of what I have going on, albeit with much more complicated spreadsheets. I treid just now making really basic ones and can't duplicate the issue. So I really don't know where the issue is.

    I don't mind sharing my workbooks with you to take a look though.

    Monday, January 7, 2019 4:08 AM
  • Here is a link to the workbooks. Opening the Main in combination with any of the others in the sub directories is what causes the issue. One by one, all work fine. It's also an issue to open any combination of two or more in the sub directories. While two are open, switch between the two.

    All queries should work as long as the folder structure remains intact.

    https://drive.google.com/open?id=1z2IIb1pGKjQeb9TYrxpB38wJRJbdGtO2


    • Edited by foloko Monday, January 7, 2019 5:48 AM
    Monday, January 7, 2019 5:46 AM
  • Still waiting on a possible solution to this. Pretty sure I have narrowed down the issue to the queries being refreshed while another workbook is active. This thread on stack overflow basically talks about the same issue. Certainly seems like a bug.

    https://stackoverflow.com/questions/48215569/excel-power-query-gives-an-error-finding-a-named-range-when-multiple-workbooks-a

    Saturday, January 12, 2019 3:13 AM
  • Anyone?
    Sunday, January 20, 2019 7:23 PM
  • Hi foloko,

    Thanks for sharing this with us.
    We submitted a fix to this issue. The fix should be released during February.

    Thanks,
    Tal - Excel team

    Tuesday, January 22, 2019 5:30 PM
  • Dear All,

    was this solved already?

    I get the same message.

    I have got PowerShell script which runs refresh of several XLSX with Power Queries. Powershell is planed to start at night (using Schedule Tasks).

    In the morning I found this error message since few days.

    But when I run the same PowerShell script during the day, it works fine.

    Thanks a lot

    Error Message details:

    Feedback Type:
    Frown (Error)
    
    Error Message:
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    
    Stack Trace:
       at Microsoft.Mashup.Client.Excel.Shim.NativeActionScopeFactory.ActionScope.Dispose()
       at Microsoft.Mashup.Client.Excel.Shim.NativeCoAuthServices.InvokeCoauthAction(IWorkbook workbook, UndoableActionType actionType, Action action)
       at Microsoft.Mashup.Client.Excel.Shim.NativeCoAuthServices.InvokeCoauthAction(IWorkbookIdentity workbookIdentity, UndoableActionType actionType, Action action)
       at Microsoft.Mashup.Client.Excel.Fill.FillManager.ForEachFillSessionByWorkbook(Action`1 action)
       at Microsoft.Mashup.Client.Excel.Fill.PassiveFillManager.<OnFillUpdateTimerTick>b__10_0()
       at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
    
    Stack Trace Message:
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    
    Invocation Stack Trace:
       at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
       at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo..ctor(String message, Exception exception, Nullable`1 stackTraceInfo, String messageDetail)
       at Microsoft.Mashup.Client.Excel.Native.NativeUserFeedbackServices.RaiseErrorDialog(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, LocalizedString dialogTitle, LocalizedString dialogMessage, Boolean useGDICapture)
       at Microsoft.Mashup.Client.Excel.Native.NativeUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
       at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.<HandleException>b__0()
       at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
       at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    Supports Premium Content:
    True

    Wednesday, May 15, 2019 5:47 AM
  • Can you provide an update on the fix. Still getting the error when running the power query.

    Best Regards,

    Paul

    Friday, December 27, 2019 12:30 AM
  • Hi Paul,

    Please upgrade to the latest version. The instruction on how to upgrade are here.

    If the error continues, please let me know on this thread and provide your Excel version and repro steps so I'll be able to reproduce the problem locally.


    Guy Hunkin - Excel Team

    Friday, December 27, 2019 1:40 PM