标签: win32exception

没有应用程序与指定的文件异常相关联

UnhandledException: System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName)
Run Code Online (Sandbox Code Playgroud)

嗨,大家好,

我在尝试使用Process.Start打开.csv文件时正在测试的一台计算机上遇到以下异常.我认为这是因为没有为此框中的.csv文件设置文件关联.

那你怎么能避免这种情况呢?

强制Process.Start在记事本中打开? - 理想情况下它应该在excel中打开,但如果excel在那台计算机上不存在,你会怎么做?

谢谢

c# notepad exception-handling win32exception process.start

6
推荐指数
2
解决办法
1万
查看次数

WindowsBase.dll中出现"System.ComponentModel.Win32Exception"类型的第一次机会异常

我有一个.NET 4.0 WPF项目.

当我打开FileDialog时,选择一些文件然后按OK按钮,然后我在输出窗口中看到这个错误:

WindowsBase.dll中出现"System.ComponentModel.Win32Exception"类型的第一次机会异常

OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Multiselect = true;

            DialogResult result = fileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
Run Code Online (Sandbox Code Playgroud)

为什么我在if语句之前得到了Exception?

.net wpf openfiledialog win32exception

5
推荐指数
1
解决办法
5619
查看次数

Win32Exception:System.Diagnostics.ProcessManager.OpenProcess() 中的访问被拒绝

首先,我是一个幼稚的开发者,对这些代码没有太深入的理解。我在尝试获取应用程序之一的版本号的代码块中访问被拒绝。

场景:在 Visual Studio 中运行代码时没有问题。但是,当安装文件在不同的计算机上运行并检查日志时,它会抛出Win32Exception:访问被拒绝。

(程序在安装后立即自动运行。实际上,在安装此应用程序之前,已经安装了一个看门狗服务,该服务会自动运行该应用程序并在关闭时恢复它。所以,我相信我无法将requestedExecutionLevel设置为requireAdmin,它可能会显示确认对话框并给用户对运行应用程序的控制。)

我需要解决这个问题。在阅读了一些博客后,我认为这一定是由于缺乏足够的权限来检索所需信息。但我仍然不清楚如何解决/解决这个问题。

日志文件中的异常:

[  1,11216] 2017-04-17T11:43:53 - -------------------- Win32Exception caught --------------------
[  1,11216] 2017-04-17T11:43:53 - Access is denied
[  1,11216] 2017-04-17T11:43:53 - (Win32Err=0x00000005)
[  1,11216] 2017-04-17T11:43:53 - Stack trace is : 
[  1,11216] 2017-04-17T11:43:53 -    at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
   at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
   at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
   at System.Diagnostics.Process.get_MainModule()
   at IMPMDesktopClient.BaseIMClientDriver.GetVersion(UIntPtr windowUIntPtr)
   at IMPMDesktopClient.WindowDetector.Hooks.WindowsEventArgs..ctor(Int32 eventNum, UIntPtr windowHandle, Int32 idObject, Int32 idChild, String clsName, Rectangle pos)
   at IMPMDesktopClient.WindowDetector.Hooks.EventHooks.CheckForWindowOfInterest(UIntPtr hWnd, …
Run Code Online (Sandbox Code Playgroud)

c# system.diagnostics process watchdog win32exception

5
推荐指数
1
解决办法
1万
查看次数

Win32Exception参数不正确

exe文件使用Process.Start()但它抛出"Win32Exception参数不正确".

Process p = new Process();
Process.Start("C:\Program Files\APS2PP\keyl2000.exe");
Run Code Online (Sandbox Code Playgroud)

我可以通过命令提示符成功运行此文件.

c# win32exception process.start

4
推荐指数
1
解决办法
1万
查看次数

什么是 Win32 错误代码的大写文本标识符,以及如何在给定错误代码的情况下以编程方式确定它们?

Win32 错误代码列表中,每个错误都有三个组成部分:

  • 数字错误代码
  • 描述性消息
  • 由下划线分隔的大写单词组成的标识符

根据文档,术语“消息标识符”指的是描述性消息,但它没有说明大写错误名称的术语是什么,而且我在任何地方都找不到。这些标识符似乎类似于 PowerShell ErrorRecord 对象中所谓的“错误 ID”,但在谷歌上搜索“win32 错误 id”和“win32 错误标识符”并没有找到答案。

例如,在以下错误中:

ERROR_TOO_MANY_OPEN_FILES

4 (0x4)

系统无法打开文件。

  • 4错误代码
  • The system cannot open the file.消息标识符
  • ERROR_TOO_MANY_OPEN_FILES 是个 __________?

另外,在给定错误代码的情况下,如何确定此文本值?我可以轻松确定与给定错误代码相关联的消息标识符,如下所示:

string MessageIdentifier = new Win32Exception(ErrorCode).Message;
Run Code Online (Sandbox Code Playgroud)

但是,Win32Exception 类似乎没有与这些大写错误名称对应的属性(类似于 ErrorRecord 类的ErrorId属性)。

在一些清单中,我看到这些类型的标识符称为“常量”,但如果它们是常量,它们在哪里定义/枚举以及如何从程序访问它们?

c# winapi error-code win32exception

3
推荐指数
1
解决办法
589
查看次数

HRESULT异常

是否有任何列表可以解释错误代码.Eks:HRESULT:0x81070215并没有告诉我什么时候错了?

.net win32exception

2
推荐指数
1
解决办法
2554
查看次数

获取进程信息时出现System.ArgumentException和System.ComponentModel.Win32Exception

当我尝试将进程'信息写入控制台时,我得到System.ArgumentException和System.ComponentModel.Win32Exception.是什么导致这个?我怎么能停止那些?

        Process processListe = Process.GetProcesses();


            for (int i = 0; i < processListe.Count(); i++)
            {
                try
                {
                string companyName = processListe[i].MainModule.FileVersionInfo.CompanyName;
                string fileVersion = processListe[i].MainModule.FileVersionInfo.FileVersion;

                Console.WriteLine(companyName  + " " + fileVersion);


                }
                catch (Exception) { }


            }
Run Code Online (Sandbox Code Playgroud)

错误发生在"string companyName = processListe [i] .MainModule.FileVersionInfo.CompanyName;"中 线.

错误消息:

   System.ArgumentException: Illegal characters in path.
   at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
   at System.IO.Path.GetFullPath(String path)
   at System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String …
Run Code Online (Sandbox Code Playgroud)

c# win32exception argumentexception

2
推荐指数
1
解决办法
9977
查看次数