Thursday, August 27, 2015

Invalid package family name: Appname_q6srzhww6szzg (expected: Appname_e0kvyw5mrygy8)

Problem:

Trying to submit a Windows Phone Silverlight 8.1 app to the Windows Store and getting this error.
I was puzzled by the error so I started to play around with the Package.appxmanifest file.


Solution:

Listed with this error was also a related Invalid Publisher Name which was the underlying issue.  I had mistyped my publisher name.  This should be 36 character GUID and I had only 32 characters.
Once I had corrected the incorrect publisher name, the package family name was corrected.  This helped me understand that the package publisher GUID is being used to generate the unique id tacked onto the end of the package family name.

Needed to use the correct publisher name.  This is listed on your app identity page https://dev.windows.com/en-us/dashboard/apps/{App ID}/Identity

Source:

See my post coming later this week...

Wednesday, August 26, 2015

“Unable to connect to a phone. Make sure the Windows Phone IP over USB transport service is running”

Problem

Upgraded to Windows 10 and now VS will not connect to my windows phone over the usb cable!

Solution

  1. Restart IpOverUsbSvc service. (Control Panel > Administrative Tools > Services)
  2. Restart phone, and turn off Set Automatic in date+time.

Source

http://stackoverflow.com/questions/24153897/getting-error-unable-to-connect-to-a-phone-make-sure-the-windows-phone-ip-over

Tuesday, August 18, 2015

Windows Phone kill application everytime

Problem:


One issue I have with a windows application is application lifecycle.  I need to make sure that the app is terminated each time a user leaves the app.  The app can be Closed or deactivated.  The deactivation can leave the app running in the background.

 

Solution:

Add the following code block to the App.xaml.cs at the root level of your windows phone project.
Locate the method Application_Deactivated.

private void Application_Deactivated(object sender, ClosingEventArgs e)
{
      App.Current.Terminate();
}

MVVMCross - System.Reflection.TargetInvocationException was unhandled Message: An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Windows.ni.dll

Problem:


I have my Windows phone project working great with my pcl core.  The MVVMCross libraries are working without issue.  What I have occurring is bug in the UI.  I open my app and run it just fine.  I then hit the windows button which puts the application into background.

When I reactivate the application it crashes with this error:

System.Reflection.TargetInvocationException was unhandled Message: An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Windows.ni.dll

Solution:

I thought at first it would be an IoC error but it occurs to early for that.  I had to set a breakpoint in the app.xaml.cs in the Windows UI project.  The key was to set it at the Application_Activated event.
Otherwise the crash occurs and it goes straight to the dump.  I was able to walk through the issue until I hit the event RootFrame_NavigationFailed event.  Here I discovered the issue.  I took a look at the e.Exception (e is type NavigationFailedEventArgs).

e.Exception

{System.InvalidOperationException: No XAML found at the location /MainPage.xaml ...

So that was my issue!   The modifications to use MVVMCross means we do not need this page since the setup.cs file does the IoC transfer of the app at startup.  This transfer pushes control down to the PCL layer. My oversight was that the WMAppManifest.xml file has a navigation Page attribute which was set too MainPage.xaml.


NOTE to MVVMCross Users:
What I neglected to do was what Stuart Lodge points out in his N+5 series.  The key event RootFrameOnNavigation in App.xaml.cs needs to handle the IoC redirection.  I did not do this in my Windows project.  Thus the event should include the following code

Fix 1:
private void RootFrameOnNavigating(object sender, NavigatingCancelEventArgs args)
{
args.Cancel = true;
RootFrame.Navigating -= RootFrameOnNavigating;
RootFrame.Dispatcher.BeginInvoke(() => { Cirrious.CrossCore.Mvx.Resolve<Cirrious.MvvmCross.ViewModels.IMvxAppStart>().Start(); });
}

Fix 2:
I continued to have problems due to some code I dropped into the InitializePhoneApplication event.
It says don't touch very clearly!  I did anyway and this was also causing load time issues.  I eliminated my extra code and the method should look like this:

// Do not add any additional code to this method
private void InitializePhoneApplication()
{

            if (phoneApplicationInitialized)

                return;
            // Create the frame but don't set it as RootVisual yet; this allows the splash
            // screen to remain active until the application is ready to render.
            RootFrame = new PhoneApplicationFrame();
            RootFrame.Navigated += CompleteInitializePhoneApplication;

            // Handle navigation failures
            RootFrame.NavigationFailed += RootFrame_NavigationFailed;

            // Ensure we don't initialize again
            phoneApplicationInitialized = true;
}


Now that I have done both of these steps I no longer receive the error.

Source:
  1. https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/blob/master/N-05-MultiPage/MultiPage.Phone/App.xaml.cs
  2. http://mvvmcross.blogspot.com/

Monday, August 17, 2015

Using Conditional Compilation Symbols

Problem:
I have a Portable Change Library (PCL) as core project in a mobile MVVMCross solution.  The code supports Anrdroid, Windows Phone and iPhone.  I have been trying to compile specific code for use with Windows Phone.  I had the code working but was unsure how to proceed to support the other 2 UIs which use the PCL.

Solution:
I read John Atten's excellent article on how to leverage Conditional Compilation on Visual Studio.
I defined the tag - MVVMCross_WP8 and added that to the build profile for Windows Phone.  I added the tag in the properties > build for the PCL core.


Source:
http://typecastexception.com/post/2012/08/18/Visual-Studio-Use-Conditional-Compilation-to-Control-Runtime-Settings-for-Different-Deployment-Scenarios.aspx

MVVMCross Core solution throws error - Unhandled managed exception

Problem:

I just completed the Windows Phone UI project for an MVVMCross solution.  The core project is used by iPhone and Windows Phone UI.  Upon completion of testing for WP, I decided to run a few tests against iPhone which I had completed earlier.  I was immediately confronted with an error -

"An Unhandled exception occurred"

The Xamarin log shows the error occurring at load time.  The compiler built out the bits.  The attempt to run in debug did reveal some more interesting leads. 

[3641:134567] Unhandled managed exception: Could not load file or assembly 'Windows' or one of its dependencies.  The system cannot find the file specified.  (System.IO.FileNotFoundException)

I continued to play around with the changes I had made to the Core PCL.  Then I found the issue.

Solution:

In the course of building the Windows Phone project I used the LongListSelector. This Windows Phone control has several dependcies which are specific to Windows Phone.  The Core PCL included some code which depended on the library Microsoft.Phone.dll.  This reference is not compatible with the Monotouch framework.  My code worked fine when I compiled to Windows Phone but as soon as I tried to run the exe to Monotouch I raised the error. 

My solution was to surround the code with conditional compilation commands

#if USE_MVVMCROSS_WP8

....

#endif

Source:
http://typecastexception.com/post/2012/08/18/Visual-Studio-Use-Conditional-Compilation-to-Control-Runtime-Settings-for-Different-Deployment-Scenarios.aspx

Thursday, August 13, 2015

Flush dns settings for Windows

Problem:

Brought my development box back onto the disconnected LAN.  I have the mac box running dns.
I connected my PC but it refused to acquire a new dns.  How to force the DNS to refresh?

Solution:
Ensure that the DNS service is still running on the Mac.  Mine had stopped which was the issue.
Once I restarted the Mac, I did the following commands:

cmd prompt (Admin)

ipconfig /flushdns

ipconfig /release

ipconfig /renew



Source:

http://www.techmynd.com/how-to-flush-dns-get-new-dynamic-ip/