简体   繁体   English

在应用程序启动时出现EntryPointNotFoundException TaskDialog,但稍后运行良好

[英]EntryPointNotFoundException TaskDialog at start of Application but runs fine later

I have the TaskDialog source directly from the WindowsAPI Pack for .NET (The wrapper) but whenever I try and open a TaskDialog straight in the static void Main() area of my program it throws an EntryPointNotFoundException. 我直接从Windows API Pack for .NET(包装器)获得TaskDialog源,但是每当我尝试直接在程序的静态void Main()区域中打开TaskDialog时,都会抛出EntryPointNotFoundException。 However the TaskDialog spawns and shows perfectly fine later on in my code. 但是TaskDialog会在我的代码中生成并显示得很好。 Why's this? 怎么会这样

The code that throws the EntryPointNotFoundException is 引发EntryPointNotFoundException的代码是

/// <summary>
/// TaskDialogIndirect taken from commctl.h
/// </summary>
/// <param name="pTaskConfig">All the parameters about the Task Dialog to Show.</param>
/// <param name="pnButton">The push button pressed.</param>
/// <param name="pnRadioButton">The radio button that was selected.</param>
/// <param name="pfVerificationFlagChecked">The state of the verification checkbox on dismiss of the Task Dialog.</param>
[DllImport("ComCtl32", CharSet = CharSet.Unicode, PreserveSig = false)]
internal static extern void TaskDialogIndirect(
    [In] ref TASKDIALOGCONFIG pTaskConfig,
    [Out] out int pnButton,
    [Out] out int pnRadioButton,
    [Out] out bool pfVerificationFlagChecked);

But what throws me is the fact that identical code in different places can work once but not at another time. 但是让我吃惊的事实是,相同的代码在不同的地方可以一次工作,而不能在另一个时间工作。 It could be something to do with the program not loading references or something but it just blows my mind. 这可能与程序未加载引用或其他原因有关,但这让我很惊讶。 The code at the entry point of my app is 我应用程序入口点的代码是

try
{
    var taskDialog = new TaskDialog();
    taskDialog.WindowTitle = ".NET Update Notification";
    taskDialog.MainInstruction = "";

    taskDialog.MainIcon = TaskDialogIcon.Error;

    taskDialog.EnableHyperlinks = true;
    taskDialog.Content =
        "Your .NET Framework Version is out-of-date.\nPlease see <a href=\"***********\">the forums</a> for more info.\n\nSorry, but I can't continue without it.\n\n If you had the correct install this message wouldn't appear.";

    taskDialog.Callback =
        new TaskDialogCallback((ActiveTaskDialog _taskDialog, TaskDialogNotificationArgs _args, object _callbackData) =>
            {
                if (_args.Notification == TaskDialogNotification.HyperlinkClicked)
                {
                    Process.Start(_args.Hyperlink);
                }
                return false;
            });

    var doItButton = new TaskDialogButton();
    doItButton.ButtonId = 101;
    doItButton.ButtonText = "Quit";

    taskDialog.Buttons = new TaskDialogButton[] { doItButton };

    int result = taskDialog.Show(null);
    Application.Exit();
}
/*
* Handles the error message regarding ComCtl32.dll not being found.
* In the event of the beautiful TaskDialog above (which uses ComCtl32.dll)
* cannot be opened, fall back to an ugly as **** MessageBox with a '?' Help
* button in the title bar -.-
*/
catch (EntryPointNotFoundException)
{
    MessageBox.Show(
        "Your .NET Framework Version is out-of-date.\nTo find out how to get .NET 4.0 simply visit the forums at *********.\n\nSorry, but I can't continue without it :(",
        ".NET Update Notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

Thanks for your time :) 谢谢你的时间 :)

Josh 乔希

Try this solution from MSDN - 从MSDN尝试此解决方案-

Step 1: Right Click on your project in the solution explorer 步骤1:在解决方案资源管理器中右键单击您的项目

Step 2: Select -> Add -> New Item 步骤2:选择->添加->新项目

Step 3: Add an Application Manifest File which is app.manifest in VS 2010 步骤3:添加一个应用程序清单文件,该文件在VS 2010中为app.manifest

Step 4: Uncomment the last xml section starting from the dependency tag upto /dependency 步骤4:取消注释最后一个xml节,从依赖项标签开始直到/ dependency

the Code should look something like this - 该代码应如下所示-

<dependency>
<dependentAssembly>
 <assemblyIdentity
  type="win32"
  name="Microsoft.Windows.Common-Controls"
  version="6.0.0.0"
  processorArchitecture="*"
  publicKeyToken="6595b64144ccf1df"
  language="*"
 />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在C#中使用TaskDialog时的EntryPointNotFoundException - EntryPointNotFoundException when using TaskDialog in C# 一个DLL中的EntryPointNotFoundException,而在另一个DLL中似乎很好 - EntryPointNotFoundException in one DLL while seems fine in another 启动应用程序时advapi32.dll中的EntryPointNotFoundException - EntryPointNotFoundException in advapi32.dll while starting application WPF中的TaskDialog - TaskDialog in WPF 2/4 System.Threading.Timers不在服务器上启动,但在本地运行良好 - 2 of 4 System.Threading.Timers don't start on the server, but runs fine locally Linq to SQL:查询在SQL Server Management Studio中运行良好,但在应用程序上超时 - Linq to SQL: Query runs fine in SQL Server Management Studio, but times out on the application Visual Studio设计器不会显示我的用户控件,但可以正常运行应用程序 - Visual studio designer wont display my user controls but runs the application fine PInvoke 和 EntryPointNotFoundException - PInvoke and EntryPointNotFoundException ASP.NET Core 2.0 Web 应用程序在将项目部署到 Azure Web 服务时失败并出现 SQLite 错误,但在本地环境中运行良好 - ASP.NET Core 2.0 Web Application fails with a SQLite error when deploying the project to Azure Web Service but runs fine in local environment ASP.NET Core 1.1 在本地运行良好,但在发布到 Azure 时显示“启动应用程序时出错”。 - ASP.NET Core 1.1 runs fine locally but when publishing to Azure says “An error occurred while starting the application.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM