C# Vista TaskDialog包装器:在DLL“ComCtl32”中找不到名为“TaskDialogIndirect”的入口点

C# Vista TaskDialog包装器:在DLL“ComCtl32”中找不到名为“TaskDialogIndirect”的入口点,c#,excel-dna,C#,Excel Dna,我正在尝试使用,但遇到以下异常: 在DLL“ComCtl32”中找不到名为“TaskDialogIndirect”的入口点 …在一个简单的控制台应用程序中: class Program { [STAThread] static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentT

我正在尝试使用,但遇到以下异常:

在DLL“ComCtl32”中找不到名为“TaskDialogIndirect”的入口点

…在一个简单的控制台应用程序中:

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

        PSTaskDialog.cTaskDialog.MessageBox(
            "MessageBox Title",
            "The main instruction text for the message box is shown here.",
            "The content text for the message box is shown here and the text willautomatically wrap as needed.",
            PSTaskDialog.eTaskDialogButtons.YesNo,
            PSTaskDialog.eSysIcons.Information
        );
     }
}
我做错了什么

更新:

实际上,我正在使用Excel dna开发一个Excel插件。如何控制Excel加载的dll


我已经有一段时间没有使用Office编程了,但我猜Excel会同时加载两个版本的comctl32,因此您可能需要使用激活上下文API将代码定向到包含TaskDialog的版本。解决问题而非解决方案的一些想法如下:

出于测试目的,对活动流程中的所有模块进行临时枚举-只是为了检查是否实际加载了6.10。请参见下面的一个简单示例,了解此类枚举,尽管目的不同

使用以获得正确的版本

或者,我从来没有让它在我工作过的WPF应用程序中可靠地工作过,创建一个对话框抽象类,根据您可用的版本,它会返回到MessageDlg。也许有更好的检查方法,但是…:

模块的枚举:

internal static FileVersionInfo GetLoadedModuleVersion(string name) { Process process = Process.GetCurrentProcess(); foreach (ProcessModule module in process.Modules) { if (module.ModuleName.ToLower() == name) { return module.FileVersionInfo; } return null; } }
除了所有其他人所说的之外:如果将PSTaskDialog上的ForceSimulationMode设置为true,则此错误将消失。

您看到了吗?在一个简单的控制台中,应用程序是关键。除非提供清单,否则总是加载错误版本的ComCtl32.dll。Winforms应用程序通过Application.EnableVisualStyles,WPF是不确定的。我尝试了与中相同的步骤,但出现了相同的错误。解决方案:该解决方案并不是仅仅解决问题。是的,这就是解决方案的作用。它修复了症状,但没有修复原因。事实上,我并不认为这是投反对票的理由。但是,在大多数情况下,OP无法让其应用程序加载正确版本的DLL,因此使用ForceSimulationMode仍允许OP使用PSTaskDialog而不会出错。 internal static FileVersionInfo GetLoadedModuleVersion(string name) { Process process = Process.GetCurrentProcess(); foreach (ProcessModule module in process.Modules) { if (module.ModuleName.ToLower() == name) { return module.FileVersionInfo; } return null; } }