如何在执行CodedUI测试时解决管理异常 [英] How to resolve Management exceptions while executing CodedUI tests

查看:79
本文介绍了如何在执行CodedUI测试时解决管理异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Coded UI来自动化Windows应用程序。我需要获取应用程序的进程详细信息,以便在每次测试运行后终止进程。


在访问进程时,会显示异常后的详细信息;



  • process.MainModule.FileName ='process.MainModule.FileName'引发类型'System.ComponentModel.Win32Exception'的异常

这当我们执行   return process.MainModule.FileName;声明



  • System.Management.dll中发生了'System.Management.ManagementException'类型的异常,但未在用户代码中处理


           其他信息:违反配额



我在执行以下代码时遇到异常;


string query =" SELECT ExecutablePath,ProcessID FROM Win32_Process" ;;

                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);



                foreach(searcher.Get()中的ManagementObject项)

                {

                    object id = item [" ProcessID"];

                    object path = item [" ExecutablePath"];
$


                    if(path!= null&& id.ToString()== process.Id.ToString())

                    {

                        return path.ToString();

                    }¥b $ b                }



我只在Windows 10企业版机器上遇到此问题。这些脚本在Windows 7计算机上成功运行。


VS版本:Enterprise 2015 - update3


这是否与WMI有关。如何解决此问题?



解决方案

也许这会有所帮助



https://stackoverflow.com/questions/26229344/how-to-prevent-wmi-quotas-from-overflowing


I am using Coded UI for automating a windows application. I need to get the process details of the application for killing the process after each oredered test run.

While accessing the process details following exception is shown;

  • process.MainModule.FileName = 'process.MainModule.FileName' threw an exception of type 'System.ComponentModel.Win32Exception'

This happens when we execute  return process.MainModule.FileName; statement

  • An exception of type 'System.Management.ManagementException' occurred in System.Management.dll but was not handled in user code

           Additional information: Quota violation

I am getting above exception while executing the following piece of code;

string query = "SELECT ExecutablePath, ProcessID FROM Win32_Process";
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

                foreach (ManagementObject item in searcher.Get())
                {
                    object id = item["ProcessID"];
                    object path = item["ExecutablePath"];

                    if (path != null && id.ToString() == process.Id.ToString())
                    {
                        return path.ToString();
                    }
                }

I am getting this issue in Windows 10 Enterprise edition machine only. These scripts were running successfully in windows 7 machines.

VS edition: Enterprise 2015 - update3

Is this something related to WMI. How can I resolve this issue?

解决方案

Maybe this will help

https://stackoverflow.com/questions/26229344/how-to-prevent-wmi-quotas-from-overflowing


这篇关于如何在执行CodedUI测试时解决管理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆