5

私はWindows Phoneの開発に非常に慣れていません。Windows 8 のスマートフォンをラップトップに接続したときに起動するアプリを開発したいと考えています。このチュートリアル ( http://justinangel.net/WindowsPhone7EmulatorAutomation ) に従っていて、Windows 7 の電話/エミュレーターに接続できましたが、Windows 8 の電話またはエミュレーターに接続できません。Windows 8 phone に接続する他の方法はありますか?

この問題の解決策があれば教えてください。

ありがとうございました

4

2 に答える 2

7

このブログ記事を更新する機会がまだありませんでした。Delvis Gomez (私の同僚) は、最終的なコード サンプルを更新し、自由に配布することを許可しました。将来的に WP8 のブログ投稿を更新しますが、当面は、WP8 エミュレーターを自動化する方法について、かなり詳細に文書化されたコード スニペットを以下に示します。

また、Microsoft.SmartDevice.MultiTargeting.Connectivity など、必要な新しい DLL への参照を必ず追加してください。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.Reflection;

// Libraries needed to connect to the Windows Phone X Emulator
using Microsoft.SmartDevice.Connectivity;
using Microsoft.SmartDevice.Connectivity.Interface;
using Microsoft.SmartDevice.MultiTargeting.Connectivity;
using System.Globalization;
using System.Collections.ObjectModel;


namespace AutomatedUnitTestDriver
{
    class Program
    {
        static void Main(string[] args)
        {
            MultiTargetingConnectivity connectivity = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID);

            // Get a connectable device for a specific Device ID (from the CoreCon datastore)
            string deviceId = "5E7661DF-D928-40ff-B747-A4B1957194F9";
            ConnectableDevice connectableDevice = connectivity.GetConnectableDevice(deviceId);
            Console.WriteLine("Found Connectable Device \'" + connectableDevice.Name + "\' for Device id {" + connectableDevice.Id + "}.");

            // Connect to the Device
            Console.WriteLine("Connecting to Device...");
            IDevice iDevice = connectableDevice.Connect();
            Console.WriteLine("Done!");

            // Check if the application is already install, if it is remove it (From WMAppManifect.xml)
            Guid appID = new Guid("{b6635769-b7ac-41a5-915d-5a7b0ae34481}"); 

            if (iDevice.IsApplicationInstalled(appID))
            {
                Console.WriteLine("Uninstalling application...");
                iDevice.GetApplication(appID).Uninstall();
                Console.WriteLine("Done!");
            }

            Guid productId = appID;
            Guid instanceId = appID;
            string applicationGenre = "NormalApp";
            string iconPath = @"C:\Share\LatestAPI\TestCode\Automated\AutomatedUnitTests\Bin\Debug\ApplicationIcon.png";
            string xapPackage = @"C:\Share\LatestAPI\TestCode\Automated\AutomatedUnitTests\Bin\Debug\AutomatedUnitTests.xap";

            // Install the application 
            Console.WriteLine("Installing the application...");
            IRemoteApplication remoteApplication = iDevice.InstallApplication(appID, appID, applicationGenre, iconPath, xapPackage);
            Console.WriteLine("Done!");

            // Launch the application
            Console.WriteLine("Starting the application...");
            remoteApplication.Launch();

            int startStopWaitTime = 1000;   // msec
            int executionWaitTime = 180000; // msec

            // Note that IRemoteApplication has a 'IsRunning' method but it is not implemented.
            // So, for the moment we sleep few msec.
            Thread.Sleep(startStopWaitTime);
            Console.WriteLine("Done!");

            // Allow application to complete 
            Console.WriteLine("Application is running! Waiting few seconds...");
            Thread.Sleep(executionWaitTime);

            try
            {
                IRemoteIsolatedStorageFile remoteIsolatedStorageFile = remoteApplication.GetIsolatedStore();
                string sourceDeviceFilePath = (object)Path.DirectorySeparatorChar + "TestResults.trx";
                string targetDesktopFilePath = @"C:\Share\LatestAPI\TestCode\Automated\AutomatedUnitTests\Bin\Debug\" + "TestResults.trx";
                remoteIsolatedStorageFile.ReceiveFile(sourceDeviceFilePath, targetDesktopFilePath,true);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception \'" + exception.Message + "\' reading file from device.");
            }

            // Terminate application
            Console.WriteLine("Terminating the application...");
            remoteApplication.TerminateRunningInstances();

            Thread.Sleep(startStopWaitTime);
            Console.WriteLine("\nDone!");

            // Disconnect from the emulator
            Console.WriteLine("Disconnecting Device...");
            iDevice.Disconnect();
            Console.WriteLine("\nDone!");
        }
    }
}
于 2012-11-17T10:32:25.767 に答える
0

これらの名前空間の参照が見つからなかったため、受け入れられたソリューションの実装に問題がありました。

Microsoft.SmartDevice.Connectivity.Interface
Microsoft.SmartDevice.MultiTargeting.Connectivity

ここに私が見つけた場所があります:

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\
   Microsoft.SmartDevice.Connectivity.Interface\
   v4.0_11.0.0.0__b03f5f7f11d50a3a\
   Microsoft.Smartdevice.Connectivity.Interface.dll

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\
   Microsoft.SmartDevice.MultiTargeting.Connectivity\
   v4.0_11.0.0.0__b03f5f7f11d50a3a\
   Microsoft.Smartdevice.MultiTargeting.Connectivity.dll

これらのパス、特にv4.0_11.0.0.0__b03f5f7f11d50a3aパーツは、システムによって異なる場合があることに注意してください。プロジェクトにこれらの DLL への参照を追加すると、すべてが正しく機能するはずです。

于 2013-09-18T19:38:21.060 に答える