dotnet / dotnet/wpf

Calls to comctl32.dll succeed in .NET 4.8, but fail in .NET 5 with System.EntryPointNotFoundException

Open
#6,810 28 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: **5.0.100** and **3.1.404**
* Windows version: **Windows 10** (18363.1139)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: **No**
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? **No**

**Problem description:**

Calls to `comctl32.dll` succeed in .NET Framework 4.8, but fail in .NET 5 and also in .NET Core 3.1 with a `System.EntryPointNotFoundException`.

e.g.

```csharp
[DllImport("comctl32.dll", PreserveSig = false)]
private static extern void TaskDialogIndirect([In] ref TaskDialogConfig pTaskConfig, out int pnButton,
out int pnRadioButton, [MarshalAs(UnmanagedType.Bool)] out bool pfVerificationFlagChecked);

// ...

var config = new TaskDialogConfig
{
pszWindowTitle = "Task dialog title",
pszMainInstruction = "Task dialog main instruction",
dwCommonButtons = TaskDialogCommonButtonFlags.OkButton | TaskDialogCommonButtonFlags.CancelButton,
// ...
};

using (new ComCtlv6ActivationContext(enable: true))
{
TaskDialogIndirect(ref config, out _, out _, out _);
}
```

**Actual behavior:**

![image](https://user-images.githubusercontent.com/177608/99158014-8d2d9980-26a4-11eb-95c9-8ecd3e366fff.png)

```
System.EntryPointNotFoundException: Unable to find an entry point named 'TaskDialogIndirect' in DLL 'comctl32.dll'.
at TaskDialogApi.TaskDialog.TaskDialogIndirect(TaskDialogConfig& pTaskConfig, Int32& pnButton, Int32& pnRadioButton, Boolean& pfVerificationFlagChecked)
```

**Expected behavior:**

Display the Task Dialog requested

![image](https://user-images.githubusercontent.com/177608/99158064-22309280-26a5-11eb-9d4a-fa7b5a58d6a5.png)

**Minimal repro:**

- [repro-wpf-net5-comctl32-entrypointnotfoundexception](https://github.com/augustoproiete-repros/repro-wpf-net5-comctl32-entrypointnotfoundexception)

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.