Excel-DNA / Excel-DNA/ExcelDna

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

Open
#587 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
1.5k
Forks
292
Avg merge
20d 12h
Merged PRs (30d)
1

Description

### 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](https://user-images.githubusercontent.com/22947364/229930788-c0f446ca-983f-4b12-a427-a7de57946925.png)

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](https://user-images.githubusercontent.com/22947364/229909513-a1225afc-980e-4cca-bfe6-b48c56db902f.png)

We debug the code and when the debugger reaches ExcelComAddInHelper.LoadComAddIn(_comAddIn); the "Memory" warning is displayed as below picture.
![warning](https://user-images.githubusercontent.com/22947364/229904208-fc21527a-9e19-46c1-9989-dd3c8f661995.png)

Click on Continue and the following Exception is raised.
![image](https://user-images.githubusercontent.com/22947364/229933177-e51c17e8-4082-4e9e-8afd-26c33569397b.png)

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](https://user-images.githubusercontent.com/22947364/229904844-e3190e26-31a8-4150-87ce-b57d0dd5a98d.png)

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](https://user-images.githubusercontent.com/22947364/229904909-335d81eb-6b04-4b12-85cf-69d1c99a790b.png)

3. Set Excel as Chinese language in the File-> Options->Language -> Office display language as Chinese (Simplified), as below picture
![image-20221207-134404](https://user-images.githubusercontent.com/22947364/229905050-127e3358-b943-4a9e-9907-691f3bb0e182.png)

4. Set Windows Display as Chinese
![image-20221207-134455](https://user-images.githubusercontent.com/22947364/229905084-1537bce6-b0c0-423c-ac04-bec773b5fad9.png)

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.