Connect to phone window 8 using the console application

I am very new to developing Windows phones. I want to develop an application that will be launched when I connect my Windows 8 phone to my laptop. I followed this tutorial ( http://justinangel.net/WindowsPhone7EmulatorAutomation ) and was able to connect to my Windows 7 phone / emulator, but I canโ€™t connect to my phone or Windows 8 emulator, is there any other way to connect the phone to window 8?

Please let me know if there is any possible solution for this,

thanks

+5
source share
2 answers

I did not have the opportunity to update this blog. Delvis Gomez (my colleague) updated the final code sample and OKed, distributing it freely. I will be updating this WP8 blog post in the future, but at the same time here is a pretty well-documented code snippet on how to automate the WP8 emulator.

Also, be sure to add a link to the new DLLs needed as 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!"); } } } 
+7
source

I had a problem with the implementation of the decision, because I didnโ€™t have links for these namespaces:

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

Here I found them:

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

and

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

Please note that these paths, especially the v4.0_11.0.0.0__b03f5f7f11d50a3a part, may be different on your system. Add links to these DLLs to your project, and everything should work as expected.

0
source

All Articles