Windows phone 8处于连接待机模式

本文关键字:连接 待机 模式 phone 8处 于连接 Windows | 更新日期: 2023-09-27 18:27:20

我选择了Windows驱动程序测试框架(WDTF)来支持Windows 8中的连接待机。编译时出现以下错误。

无法嵌入Microsoft.WDTF.WTF2Class"。使用适用的接口。类型"Microsoft.WDTF.WDTF2Class"没有构造函数定义的

所有dll引用都来自"C:''Program Files(x86)''Windows Kits''8.2''Testing''Development''lib''x86''"。这是我的剧本。。

    IWDTF2 wdtf = new WDTF2Class();
    IWDTFSystemDepot2 systemDepot = wdtf.SystemDepot;
    IWDTFTarget2 systemTarget = systemDepot.ThisSystem;
    IWDTFSystemAction2 systemAction = (IWDTFSystemAction2)systemTarget.GetInterface("System");
    systemAction.ConnectedStandby(1000);

Windows phone 8处于连接待机模式

我遇到了同样的问题,最终解决了它

  1. WDTF.Interop.dll
  2. WDTFSystemAction.Interop.dll

缺少第二个引用将导致您共享的错误。此外,目标计算机(Windows Surface 3平板电脑)需要安装VC Redistributable(x64),就像我使用VS2013一样,以及WDTF运行时间。WDTF运行时是作为WDK的一部分安装的([https://msdn.microsoft.com/en-us/library/windows/hardware/hh831856(v=vs.85).aspx)。在我的机器上,路径如下:

C: ''Program Files(x86)''Windows Kits''8.1''Testing''Runtimes''Windows驱动程序测试框架(WDTF)运行库-x64_en-us.msi

如果您没有安装VC Redistributable,您可能会收到一条"…计算机中缺少MSVCR120.DLL…"消息。或者,如果它被编译为"调试",那么消息可能会引用"MSVCR120D.DLL"。

如果您没有在目标机器上安装运行时,您可能会收到以下错误:

未处理的异常:System.Runtime.InteropServices.COMException:正在检索CLSID为{0D972387-817B-46E7-913F-E9993FF401E的组件的COM类工厂B} 由于以下错误而失败:80040154类未注册(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))。at System.RuntimeTypeHandle.CreateInstance(RuntimeType类型,布尔publicOn ly,布尔noCheck,布尔&canBeCached,RuntimeMethodHandleInternal&ctor,Bo olean&bNeedSecurityCheck)在System.RuntimeType.CreateInstanceSlow(布尔publicOnly、布尔skipChec kThis、布尔fillCache、StackCrawlMark和stackMark)位于System.RuntimeType.CreateInstanceDefaultCtor(布尔publicOnly、布尔s kipCheckThis、布尔fillCache、StackCrawlMark和stackMark)位于System.Activator.CreateInstance(类型类型,布尔值非公共)在System.Activator.CreateInstance(类型类型)

在完成所有这些步骤后,我能够使平板电脑进入ConnectedStandby状态。还有一点需要注意:当通过Dameware连接时,平板电脑检测到输入,并拒绝进入ConnectedStandby状态。我终于能够测试了,将这个可执行文件设置为按计划任务运行,然后ping平板电脑,看看它是否/何时失去网络连接,以及何时恢复网络连接。

注意:ConnectedStandby_SleepAndWake是我在VS2013中的项目名称。

CS、app.config和项目定义(csproj)文件如下:

*程序.cs*

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WDTF;
using System.Configuration;
namespace ConnectedStandby_SleepAndWake
{
    class Program
    {
        static void Main(string[] args)
        {
            int CSDurationMilliseconds = 0;
            DateTime wakeTime = new DateTime();
            try
            {
            if (ConfigurationManager.AppSettings["wakeTime"] != null)
            {
                wakeTime = Convert.ToDateTime(ConfigurationManager.AppSettings["wakeTime"]);
            }
            else
            {
                wakeTime = DateTime.Now.AddMinutes(2);
            }
            System.TimeSpan wakeInMs = wakeTime.Subtract(DateTime.Now);
            CSDurationMilliseconds = wakeInMs.Milliseconds;
            IWDTF2 WDTF = new WDTF2();
            IWDTFSystemAction2 Sys = (IWDTFSystemAction2)WDTF.SystemDepot.ThisSystem.GetInterface("System");
            // Sys.SleepWakeTimeInSeconds = 60;
            // Sys.Sleep(4);
            Sys.ConnectedStandby(CSDurationMilliseconds);
            }
            catch (Exception e)
            {
            }

        }
    }
}

*app.config*

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <appSettings>
    <add key="wakeTime" value="2015-08-16 01:25AM"/>
  </appSettings>
</configuration>

*ConnectedStandby_SleepAndWake.cproj*

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)'$(MSBuildToolsVersion)'Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)'$(MSBuildToolsVersion)'Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{657A21BE-8991-4E24-AB41-59D7F0C7D3EB}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ConnectedStandby_SleepAndWake</RootNamespace>
    <AssemblyName>ConnectedStandby_SleepAndWake</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <PublishUrl>publish'</PublishUrl>
    <Install>true</Install>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <UpdateMode>Foreground</UpdateMode>
    <UpdateInterval>7</UpdateInterval>
    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
    <UpdatePeriodically>false</UpdatePeriodically>
    <UpdateRequired>false</UpdateRequired>
    <MapFileExtensions>true</MapFileExtensions>
    <ApplicationRevision>0</ApplicationRevision>
    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <UseApplicationTrust>false</UseApplicationTrust>
    <BootstrapperEnabled>true</BootstrapperEnabled>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin'Debug'</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>x64</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin'Release'</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
    <Reference Include="WDTF.Interop">
      <HintPath>..'..'..'..'..'..'..'Program Files (x86)'Windows Kits'8.1'Testing'Development'lib'x64'WDTF.Interop.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
    <Reference Include="WDTFInterfaces.Interop">
      <HintPath>..'..'..'..'..'..'..'Program Files (x86)'Windows Kits'8.1'Testing'Development'lib'x64'WDTFInterfaces.Interop.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
    <Reference Include="WDTFSystemAction.Interop">
      <HintPath>..'..'..'..'..'..'..'Program Files (x86)'Windows Kits'8.1'Testing'Development'lib'x64'WDTFSystemAction.Interop.dll</HintPath>
      <EmbedInteropTypes>True</EmbedInteropTypes>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties'AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <ItemGroup>
    <BootstrapperPackage Include=".NETFramework,Version=v4.5">
      <Visible>False</Visible>
      <ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
      <Install>true</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
      <Visible>False</Visible>
      <ProductName>.NET Framework 3.5 SP1</ProductName>
      <Install>false</Install>
    </BootstrapperPackage>
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)'Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>