AnsweredAssumed Answered

Culture settings of Add-In differ from macro

Question asked by Dennis Beeren on Feb 2, 2018
Latest reply on Feb 3, 2018 by Dennis Beeren

Dear All,

 

I have a macro in which I use the method below. And as long as in the Windows region settings the decimal separator was a comma it returned true.

/**
    * Returns true if the system's decimal separator is a comma.
    */
private Boolean decimalSeperatorIsComma()
{
    char separator = Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
    if (separator.Equals(','))
    {
        return true;
    }
    mySWApp.SendMsgToUser2("Please check your regional settings." + "\n" + "\n" + "For this macro the decimal separator has to be a comma"
                            + "\n" + "Macro operation aborted.", (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk);
    return false;
}

Now I am using the same method in an add-in and it returns falls. So the numberDecimalSeparator is a dot.

Even when I fire the method in the same instance of Solidworks the method in the macro and the method in the add-in are giving different results.

Can anyone tell me how that is possible. I thought that CurrentCulture is refering to the current system settings.

I checked if there is a setting in Visual Studio, and there is (tools -> options -> environment -> international settings), but even setting it to "Same as Microsoft Windows" does not change this weird behavior. And since both macro and add-in are within the same Solidworks instance I don't think that there is a Soliworks setting that would prevent this.

I can get my head around this. Any help is really appreciated!

 

Best regards,

Dennis.

Outcomes