Skip to content

COMAddinBase will no longer call Application.EnableVisualStyles() from its constructor #488

Description

@jozefizso

Starting with NetOffice 2.0, COMAddinBase no longer calls EnableVisualStyles() from its constructor.

What Changes

Before NetOffice 2.0, add-ins derived from COMAddinBase implicitly called internal EnableVisualStyles() method:

protected internal virtual void EnableVisualStyles()
{
    lock (_lock)
    {
        if (System.Windows.Forms.Application.VisualStyleState == System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled)
            System.Windows.Forms.Application.EnableVisualStyles();
    }
} 

NetOffice 2.0 will not enable Windows Forms visual styles automatically.

Why

COMAddinBase is part of the NetOffice core library. Calling Windows Forms APIs from its constructor creates an implicit UI dependency and a side effect for every add-in, including add-ins that do not use Windows Forms user interface.

Who Is Affected

Add-ins that rely on COMAddinBase to enable Windows Forms visual styles automatically may see different Windows Forms control styling after upgrading to NetOffice 2.0.

Migration

If your add-in uses Windows Forms UI and needs visual styles, call it explicitly from your add-in startup code before creating Windows Forms controls:

System.Windows.Forms.Application.EnableVisualStyles();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

  • Status
    Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions