2012-11-16 14 views
5

Sono molto nuovo allo sviluppo del telefono Windows. Voglio sviluppare un'app che verrà lanciata quando collego il mio telefono Windows 8 al mio portatile. Stavo seguendo questo tutorial (http://justinangel.net/WindowsPhone7EmulatorAutomation) ed ero in grado di connettermi al mio telefono/emulatore di Windows 7, ma non sono in grado di collegarmi al mio telefono o emulatore di Windows 8. C'è un altro modo per connettersi al telefono di Windows 8?connettersi a Windows Phone 8 utilizzando l'applicazione console

Per favore fatemi sapere se c'è qualche soluzione possibile per questo,

Grazie

risposta

7

non ho avuto la possibilità di aggiornare questo post del blog. Delvis Gomez (un mio collega) ha aggiornato il campione finale del codice e ha fatto in modo di distribuirlo liberamente. Aggiornerò quel post sul blog per WP8 in futuro, ma nel frattempo ecco uno snippet di codice ben documentato su come automatizzare l'emulatore WP8.

Inoltre, assicurarsi di aggiungere un riferimento alle nuove DLL necessarie come Microsoft.SmartDevice.MultiTargeting.Connectivity.

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!"); 
     } 
    } 
} 
+0

Grazie mille per la risposta e la soluzione. Sono molto nuovo nello sviluppo di Windows Phone e questo è un grande aiuto per me. Grazie! – user1720839

+0

Dove posso trovare la DLL. Ho trovato Microsoft.Smartdevice.Connectivity.dll (l'ho usato per wp7) ma non ho un Microsoft.SmartDevice.MultiTargeting.Connectivity. Qualche idea? –

+0

Funziona con Windows Phone 8 su Windows 8. ma per Windows 7 non funziona. –

0

ho avuto problemi a implementare la soluzione accettato perché mi mancava il riferimento per questi spazi dei nomi:

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

Ecco dove li ho trovati:

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

e

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

Si noti che questi percorsi, in particolare la parte v4.0_11.0.0.0__b03f5f7f11d50a3a, potrebbero essere diversi sul sistema. Aggiungi riferimenti a queste DLL nel tuo progetto e tutto dovrebbe funzionare correttamente.