ExcelDna icon indicating copy to clipboard operation
ExcelDna copied to clipboard

Beta UTF-8 region setting with Chinese language displays DnaLibrary AutoOpen "Memory" warning

Open eutiquiorg opened this issue 2 years ago • 1 comments

Discussed in https://github.com/Excel-DNA/ExcelDna/discussions/586

Originally posted by eutiquiorg April 4, 2023 Hello there! We have an add-in added to Excel and when we open Excel under the conditions described below (Steps to reproduce), a "Memory" warning is displayed and then we cannot use the available functions of our add-in.

We create a simple ClassLibrary project to reproduce our problem in Visual Studio 2022 (having Visual Studio in Chinese and having the "Steps to reproduce"). image

Class1.cs 'namespace MyClassProject {

[ComVisible(true)]
public class MyComAddIn : ExcelComAddIn
{

    public MyComAddIn()
    {
    }

    public override void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
    {
        SWF.MessageBox.Show("OnConnection");
    }

    public override void OnDisconnection(ext_DisconnectMode RemoveMode, ref Array custom)
    {
        SWF.MessageBox.Show("OnDisconnection");
    }

    public override void OnAddInsUpdate(ref Array custom)
    {
        SWF.MessageBox.Show("OnAddInsUpdate");
    }

    public override void OnStartupComplete(ref Array custom)
    {
        SWF.MessageBox.Show("OnStartupComplete");
    }

    public override void OnBeginShutdown(ref Array custom)
    {
        SWF.MessageBox.Show("OnBeginShutDown");
    }
}

public class MyAddIn : IExcelAddIn
{
    private ExcelComAddIn _comAddIn;

    public void AutoOpen()
    {
        try
        {
            _comAddIn = new MyComAddIn();
            ExcelComAddInHelper.LoadComAddIn(_comAddIn);
        }
        catch (Exception e)
        {
            SWF.MessageBox.Show("Error loading COM AddIn: " + e.ToString());
        }
    }

    public void AutoClose()
    {
    }
}

}`

MyClassProject.csproj image

We debug the code and when the debugger reaches ExcelComAddInHelper.LoadComAddIn(_comAddIn); the "Memory" warning is displayed as below picture. warning

Click on Continue and the following Exception is raised. image

This behavior occurs when we enable "Beta: Use Unicode UTF-8 for worldwide language support" option in the Region Settings and set the Windows language and Office language to Chinese (See "Steps to reproduce").

Steps to reproduce:

  1. Set the Regional format to "Chinese (Simplified, China)", as below picture image-20221207-134326

  2. Set the Region setting to use "Beta: Use Unicode UTF-8 for worldwide language support", and the Current system locale option as "Chinese (Simplified, China), as below picture image-20221207-134347

  3. Set Excel as Chinese language in the File-> Options->Language -> Office display language as Chinese (Simplified), as below picture image-20221207-134404

  4. Set Windows Display as Chinese image-20221207-134455

  5. Restart Windows 10 system

  6. Run the simple ClassLibrary project, you will see the "Memory" warning.

We appreciate your help with this issue. Thank you!

eutiquiorg avatar Apr 05 '23 18:04 eutiquiorg

I replied under the original discussion.

govert avatar Apr 05 '23 20:04 govert