使用HCK API时运行可签名性测试时出错 [英] Error while running signability test while using HCK API

查看:110
本文介绍了使用HCK API时运行可签名性测试时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我遇到未处理的异常"运行可签名性测试时出错"使用HCK api运行AddDriver方法时。当我使用GUI并使用"添加驱动程序文件夹"添加相同的文件夹时按钮,一切正常。

I encounter an unhandled exception "Error while running signability test" while running the AddDriver method with HCK api. When I use the GUI and add the same folder with "Add Driver Folder" button, everything works fine.


异常后,错误计数和警告将保持为0. 

After the exception the error count and warning will remain 0. 


如何解决问题?

How can I fix the problem?


我已经包含了部分代码:

I have included part of my code:

            driverPath =" path \\to\\driver \\ folder"            

            PackageWriter packageWriter = new PackageWriter(project);

  ; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;列表<目标> targetList = new List< Target>();

&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; foreach(ProductInstance pi in project.GetProductInstances())

&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; targetList.AddRange(pi.GetTargets());

&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;列表与LT;串GT; localeList = new List< string>();

&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int index = -1;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; ReadOnlyCollection<串GT; fullLocaleList = ProjectManager.GetLocaleList();

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; foreach(fullLocaleList中的字符串值)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; index ++;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(" read:{0}",value);

&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(value.Equals(EnglishLocale))

  ; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; } 

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; localeList.Add(fullLocaleList [index]);



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; StringCollection errorMessages;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; StringCollection warningMessages;

            PackageWriter packageWriter = new PackageWriter(project);
            List<Target> targetList = new List<Target>();
            foreach (ProductInstance pi in project.GetProductInstances())
            {
                targetList.AddRange(pi.GetTargets());
            }

            List<string> localeList = new List<string>();
            int index = -1;
            ReadOnlyCollection<string> fullLocaleList = ProjectManager.GetLocaleList();
            foreach (string value in fullLocaleList)
            {
                index++;
                Console.WriteLine("read: {0}", value);
                if (value.Equals(EnglishLocale))
                {
                    break;
                } 
            }
            localeList.Add(fullLocaleList[index]);

            StringCollection errorMessages;
            StringCollection warningMessages;



if(packageWriter.AddDriver(driverPath,null ,targetList.AsReadOnly(),localeList.AsReadOnly(),out errorMessages,out warningMessages)== false)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine("添加驱动程序无法添加此驱动程序在{0}","driverPath";)
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; foreach(errorMessages中的字符串消息)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine("错误:{0}",消息);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //警告可能不会导致方法失败,但可能仍然存在

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(warningMessages.Count!= 0)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine("添加驱动程序在包中找到警告:{0}",driverPath);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; foreach(warningMessages中的字符串消息)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine("警告:{0}",消息);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }

if (packageWriter.AddDriver(driverPath, null, targetList.AsReadOnly(), localeList.AsReadOnly(), out errorMessages, out warningMessages) == false)
            {
                Console.WriteLine("Add driver failed to add this driver found at : {0}", driverPath);
                foreach (string message in errorMessages)
                {
                    Console.WriteLine("Error: {0}", message);
                }
            }

            // warnings might not cause the method to fail, but may still be present
            if (warningMessages.Count != 0)
            {
                Console.WriteLine("Add driver found warnings in the package found at : {0}", driverPath);
                foreach (string message in warningMessages)
                {
                    Console.WriteLine("Warning: {0}", message);
                }
            }



根据API,AddDriver应返回false,即使驱动程序未通过可签名性测试而不是抛出异常

推荐答案

我在使用PackageWriter.AddDriver方法之前遇到过这个错误。我发现这个异常有一个InnerException属性,暗示这个方法需要读取一个名为"WindowsProtectedFiles.xml"的文件。它应该包含在你的HCK Studio文件夹中的
,例如"C:\Program Files(x86)\Windows Kits \8.1 \ Hardware Certification Kit \ Studio"。 

I had met this error before while using the PackageWriter.AddDriver method. And I found that this exception has an InnerException property that imply this method need to read a file named "WindowsProtectedFiles.xml" which supposed to be include in your HCK Studio folder like "C:\Program Files (x86)\Windows Kits\8.1\Hardware Certification Kit\Studio". 

因此解决方案是将此"WindowsProtectedFiles.xml"文件复制到您的exe所在的文件夹中。

So the solution is copy this "WindowsProtectedFiles.xml" file to the folder that your exe located.


这篇关于使用HCK API时运行可签名性测试时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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