locked
VSTO Excel Addin get an error only on windows server 2012 RRS feed

  • Question

  • Hi,

    we have an windows server 2012 terminal server enviroment.

    We have deployed Excel Addin solution to that server, but when the addin try to open an style excel dialog box and try to modify an excel style get this error:

    Error Title 
    Client error 

    Error Message 
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 

    Exception kind 
    System.AccessViolationException 

    Stack Trace 
      at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) 
      at Microsoft.Office.Interop.Excel.Dialog.Show(Object Arg1, Object Arg2, Object Arg3, Object Arg4, Object Arg5, Object Arg6, Object Arg7, Object Arg8, Object Arg9, Object Arg10, Object Arg11, Object Arg12, Object Arg13, Object Arg14, Object Arg15, Object Arg16, Object Arg17, Object Arg18, Object Arg19, Object Arg20, Object Arg21, Object Arg22, Object Arg23, Object Arg24, Object Arg25, Object Arg26, Object Arg27, Object Arg28, Object Arg29, Object Arg30) 
      at Tgkr2007.com.tagetik.stylesheets.XLStylesBackend.EditStyle(String name, Boolean readOnly) 
      at Reporting.com.tagetik.stylesheets.StylesEditor.onEditClicked(Object sender, EventArgs e) 
      at Framework.com.tagetik.forms.EasyBaseEditorControl.btn_mod_Click(Object sender, EventArgs e) 
      at System.Windows.Forms.Control.OnClick(EventArgs e) 
      at System.Windows.Forms.Button.OnClick(EventArgs e) 
      at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
      at System.Windows.Forms.Control.WndProc(Message& m) 
      at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
      at System.Windows.Forms.Button.WndProc(Message& m) 
      at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

    I have isolated the proble in a simple addin tha you could download at the following link

    http://1drv.ms/YW1NtK 

    This is the piece of code that raise the error

     string filename = Path.GetTempPath() + "\\Sili.xslx";
                FileUtils.WriteByteArray(ExcelAddIn2.Properties.Resources.Book1,filename );
               this.workbook= Globals.ThisAddIn.Application.Workbooks.Open(
                     filename,
                     true,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     Type.Missing,
                     XlCorruptLoad.xlNormalLoad
                    );
              
               this.workbook.Application.WindowState = XlWindowState.xlMinimized;
                workbook.Activate();
                Worksheet ws = workbook.ActiveSheet;
                ws.Range["A1"].Select();

                try
                {
                    //se qualcuno scopre come si fa a far aprire questa finestrella read-only mi faccia il piacere
                    //di usare il parametro readOnly, grazie.
                    bool result = Globals.ThisAddIn.Application.Application.Dialogs[XlBuiltInDialog.xlDialogApplyStyle].Show(
                    "Good", Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value
                );
                }
                catch (Exception ex)
                {

                    MessageBox.Show( ex.ToString());
                }

    Many thanks

    Floriano

    Tuesday, August 26, 2014 8:55 AM

Answers

  • Hi Floriano,

    I was able to reproduce this issue in Windows 2012 RTM Terminal Server and also Windows 8. As you had mentioned, it was not  reproducible in  Windows Server 2012 R2 and Windows 8.1.  The error looks like a known issue and can also reproduced by the following VBA code:

    Sub test()

    Application.Dialogs(xlDialogApplyStyle).Show ("good")

    End Sub

    This issue has been fixed in the latest build of Windows. I would like to suggest you to update to latest build of Windows. Thank You.

    Regards,

    Anush Rudaa

    • Proposed as answer by AnushRudaa Friday, September 5, 2014 7:30 PM
    • Marked as answer by Luna Zhang - MSFT Monday, September 15, 2014 9:41 AM
    Friday, September 5, 2014 7:30 PM

All replies

  • Hi,

    According to your description, you develop an Excel Add-in solution to deploy to windows server.

    In fact, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.

    So I recommend you find alternatives to Automation of Office if you need to develop server-side solutions. Open XML SDK can be a suitable one. There are many samples about operating Excel spreadsheet.

    By the way, after editing your code above to run in my Excel 2013 add-in on client-side, it works well without any error message. So I suspect the code is OK.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 27, 2014 6:47 AM
  • Hi Luna,

    Thank you for your answer but it's not our case, we have an SAAS environment that we use as terminal server for users that work with excel.

    Moreover we have produced the same behavior on windows 8.0 and excel 2013 SP1.
    The error doesn't appear if we deploy on windows 8.1 or windows server 2012 R2.
    It seem that it is related to these two versions of windows.

    any ideas

    Thanks

    Floriano

    Wednesday, August 27, 2014 7:29 AM
  • Hi Floriano,

    I was able to reproduce this issue in Windows 2012 RTM Terminal Server and also Windows 8. As you had mentioned, it was not  reproducible in  Windows Server 2012 R2 and Windows 8.1.  The error looks like a known issue and can also reproduced by the following VBA code:

    Sub test()

    Application.Dialogs(xlDialogApplyStyle).Show ("good")

    End Sub

    This issue has been fixed in the latest build of Windows. I would like to suggest you to update to latest build of Windows. Thank You.

    Regards,

    Anush Rudaa

    • Proposed as answer by AnushRudaa Friday, September 5, 2014 7:30 PM
    • Marked as answer by Luna Zhang - MSFT Monday, September 15, 2014 9:41 AM
    Friday, September 5, 2014 7:30 PM
  • Hi Anush,

    Thank you so much for your answer, do you have any reference  released by Microsoft that certified this problem?

    Our Customer need some official evidence of the problem.

    Thank you again 

    Best Regards

    Floriano

    Wednesday, October 1, 2014 7:14 AM