2

I've been working on an application and I was trying to follow this site to add a color picker to one of my pages but when I finally went to test a bit of what I had done so far, the app starts and exits with no information what-so-ever. Output:

'UI Task' (Managed): Loaded 'mscorlib.dll'
'UI Task' (Managed): Loaded 'System.Windows.RuntimeHost.dll'
'UI Task' (Managed): Loaded 'System.dll'
'UI Task' (Managed): Loaded 'System.Windows.dll'
'UI Task' (Managed): Loaded 'System.Net.dll'
'UI Task' (Managed): Loaded 'System.Core.dll'
'UI Task' (Managed): Loaded 'System.Xml.dll'
'UI Task' (Managed): Loaded '\Applications\Install\171F7914-3BB8-44C4-A0CE-A6B9B30A0BF5\Install\LSV_NOGPS.dll', Symbols loaded.
'UI Task' (Managed): Loaded 'Microsoft.Phone.dll'
'UI Task' (Managed): Loaded 'Microsoft.Phone.Interop.dll'
The thread '<No Name>' (0xf01016e) has exited with code 0 (0x0).
The program '[14879802] UI Task: Managed' has exited with code 0 (0x0).

The output I get from other projects seem to have more libraries being loaded and from what I can tell it may be not loading 'System.Device.dll' properly (It's the next one loaded in a normally running app).

I've seen a few very similar problems here:

WP7 App Crashes Immediately upon deploy

Windows Phone 7 - App doesn't start, no errors, just bails on load

Visual Studio 2008 would not debug

But none of the answers presented have helped me any. I haven't changed the namespace at all and I checked the 'startup' object in my properties (its set to Name of my project.App).

I've tried debugging with breakpoints at the start of the constructors and stepping into the project but every time it exits without even getting to any of my code it seems.

I've also tried making a new project, copying only the xaml and cs files into it, adding the necessary references. Same result.

I just tried making a whole new solution, new project with the same name, copying the xaml and respective cs files again. Same result, even though I forgot to add the necessary references, it doesn't even get far enough to realize there are references missing.

I'm not sure what to do other than to make a new project and go through my code, adding snippets until I hit the snag again.

I'm not new to programming but I'm pretty new to .net so go easy on me if I'm missing something obvious.

Please help! Thanks!

EDIT:

I managed to find the offending piece of code but I have no idea why it gives me this problem. I un-commented it from a working version and then I get the problem again. Its located in my App:Application cs file.

  public class ColorList {

        public ColorList() {
            this.Items = new List<ColorItem>()
             {
                 new ColorItem() {Text="orange", Color = Colors.Orange},
                 new ColorItem() {Text="red", Color = Colors.Red},
                 new ColorItem() {Text="blue", Color = Colors.Blue},
                 new ColorItem() {Text="magenta", Color = Colors.Magenta},
                 new ColorItem() {Text="purple", Color = Colors.Purple},
                 new ColorItem() {Text="green", Color = Colors.Green},
                 new ColorItem() {Text="cyan", Color = Colors.Cyan},                      
                 new ColorItem() {Text="brown", Color = Colors.Brown},
                 new ColorItem() {Text="yellow", Color = Colors.Yellow},
             };
        }

        public List<ColorItem> Items {
            get;
            set;
        }
    }

    public static ColorList theColorsList = new ColorList();

I got this code from the first link above, and I realized its a really weird way of describing the list so I just changed it to the following:

 public static List<ColorItem> ColorsList = new List<ColorItem>() {

                 new ColorItem() {Text="orange", Color = Colors.Orange},
                 new ColorItem() {Text="red", Color = Colors.Red},
                 new ColorItem() {Text="blue", Color = Colors.Blue},
                 new ColorItem() {Text="magenta", Color = Colors.Magenta},
                 new ColorItem() {Text="purple", Color = Colors.Purple},
                 new ColorItem() {Text="green", Color = Colors.Green},
                 new ColorItem() {Text="cyan", Color = Colors.Cyan},                      
                 new ColorItem() {Text="brown", Color = Colors.Brown},
                 new ColorItem() {Text="yellow", Color = Colors.Yellow}
               };

but I still get the same problem...

Community
  • 1
  • 1
  • 1
    I'll assume blank projects work? Try with a new blank project slowly adding parts. Unfortunately blunt. Alternatively, Microsoft support if you can supply a sample app with the problem. – Adam Houldsworth Mar 26 '12 at 07:20
  • Got a repro? What are the external references? What if you put a break point in the app constructor? - Does it get hit? Have you changed the start page or the default namespace? – Matt Lacey Mar 26 '12 at 09:42
  • As I stated above, I've tried with breakpoints in the constructor of App but it never gets hit. I've put debug prints in too to no avail. I went back this morning and found a couple namespace mixups in a couple pages. I fixed those but it didn't help anything. I have no clue how they got there in the first place. If I try to make a repro I'll prolly end up finding the problem myself. I think I'm just going to start clean and re-write/add everything till I hit a snag. Thanks for your replies. I'll come back and post what I find. – user1204222 Mar 26 '12 at 19:19
  • Okay so instead of rewriting everything I just commented out the work i did to add the color list and everything associated with it and it works again! I have no idea why it would cause me this problem but I'm going to go through each piece and understand what I'm doing as I go instead of trying to copy my code from someone else's page... – user1204222 Mar 26 '12 at 19:59
  • Your replacement code doesn't look to be the equivalent of the original code. If you're doing binding, you're going to need the property, not just a static member variable. – Robaticus Mar 26 '12 at 20:34
  • I can't tell.. was this question answered? – William Melani Mar 26 '12 at 20:42
  • I selected what I believe to be the answer but I just did away with going static and referencing the 'Colors' class and everything is working great for me now :) see the comment I left on the selected answer for more info – user1204222 Mar 26 '12 at 22:41

2 Answers2

2

For those who land here, see also WP7 App Crashes Immediately upon deploy

In short, changing namespaces can leave you with the startup object unset. (Right-click on the WP project and double-check that Startup object is (correctly) set).

Community
  • 1
  • 1
Andrei Rînea
  • 20,288
  • 17
  • 117
  • 166
  • 1
    thanks for this, I knew this was my problem but I couldn't remember where the property was to update it after changing the namespae. thanks! – SelAromDotNet Aug 23 '14 at 18:37
0

When you define a static field in the App.cs the field will be initialized before the constructor is called. If you have a problem in this initialization you don't even come to the constructor of App. On the other hand VisualStudio should show you the exception if one would have been thrown.

Maybe you could try to initialize ColorsList at another place, maybe the Window / UserControl that will use it and try to find out what goes wrong while initializing the list.

MatthiasG
  • 4,434
  • 3
  • 27
  • 47
  • Thanks for the answer! This seems like it may be what is going on. I ended up using some other code to initialize the list and did away with a static list all together. [My reference for the non-static list](http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=181) It provides a much greater selection for colors. – user1204222 Mar 26 '12 at 22:36