2012-11-16 32 views
5

Tôi rất mới phát triển điện thoại trên Windows. Tôi muốn phát triển một ứng dụng sẽ được khởi chạy khi tôi kết nối điện thoại Windows 8 với máy tính xách tay của mình. Tôi đã làm theo hướng dẫn này (http://justinangel.net/WindowsPhone7EmulatorAutomation) và đã có thể kết nối với cửa sổ của tôi 7 điện thoại/giả lập nhưng tôi không thể kết nối với cửa sổ của tôi 8 điện thoại hoặc giả lập. Có cách nào khác để kết nối với điện thoại windows 8 không?kết nối với windows phone 8 bằng ứng dụng giao diện điều khiển

Xin vui lòng cho tôi biết nếu có bất kỳ giải pháp khả thi cho việc này,

Cảm ơn bạn

Trả lời

7

tôi không có cơ hội để cập nhật bài viết trên blog này được nêu ra. Delvis Gomez (Một đồng nghiệp của tôi) đã cập nhật mẫu mã cuối cùng và OK phân phối nó một cách tự do. Tôi sẽ cập nhật bài đăng blog đó cho WP8 trong tương lai, nhưng trong khi đó, đây là đoạn mã được viết khá tốt về cách tự động hóa Trình mô phỏng WP8.

Ngoài ra, hãy đảm bảo thêm tham chiếu đến các DLL mới cần thiết như 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

Cảm ơn bạn rất nhiều vì đã trả lời và giải pháp. Tôi rất mới để phát triển điện thoại Windows và đây là một trợ giúp rất lớn cho tôi. Cảm ơn bạn! – user1720839

+0

Tôi có thể tìm thấy ở đâu. Tôi tìm thấy Microsoft.Smartdevice.Connectivity.dll (tôi đã sử dụng nó cho wp7) nhưng tôi không có một Microsoft.SmartDevice.MultiTargeting.Connectivity. Bất kỳ ý tưởng? –

+0

Nó hoạt động trên windows phone 8 trên windows 8 machine. nhưng đối với windows 7 thì nó không hoạt động. –

0

tôi gặp khó khăn thực hiện các giải pháp chấp nhận bởi vì tôi đã thiếu tài liệu tham khảo cho các không gian tên:

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

Đây là nơi tôi tìm thấy họ:

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 

Lưu ý rằng các đường dẫn này, đặc biệt là phần v4.0_11.0.0.0__b03f5f7f11d50a3a, có thể khác trên hệ thống của bạn. Thêm tài liệu tham khảo cho các DLL trong dự án của bạn, và mọi thứ sẽ hoạt động đúng.

Các vấn đề liên quan