C# interop and culture


  • wb = ExcelHelper.oExcelApp.Workbooks.Add();


    I have a shared Excel addin written in C# using Microsoft.Office.Interop.Excel (version 12).

    I'm using german Excel on german Windows 7.

    This addin adds several menu items to Excel.

    With one I have a strange problem.

    When this one item is invoked,

    I set System.Threading.Thread.CurrentThread.CurrentCulture to en-US at the beginning.

    several lines later I execute

    wb = ExcelHelper.oExcelApp.Workbooks.Add();

    after that System.Threading.Thread.CurrentThread.CurrentCulture  is now de-DE !

    Therefore I set System.Threading.Thread.CurrentThread.CurrentCulture again to en-US.

    Some lines latter I call and after this call System.Threading.Thread.CurrentThread.CurrentCulture  is now again de-DE !

    This behaviour of does not happen without Workbooks.Add().


    1) How can I avoid that resets System.Threading.Thread.CurrentThread.CurrentCulture after

       Workbooks.Add() ?

    2)  How can I avoid that Workbooks.Add() resets System.Threading.Thread.CurrentThread.CurrentCulture  ?

    with best regards


    Wednesday, December 12, 2012 10:22 AM

All replies