0

I just added the feature where I can make my program the default-program for multiple music filetypes by following this question on Stackoverflow

It seemed to work fine, since all of the mp3 files etc has my icon on them in Explorer.

But when I tried starting one (I have handled the arguments just fine) the process itself starts (it shows up in Task Manager) but nothing happens. I even tried adding a Messagebox in the beginning of the "Window.Initialized"-event, but no messagebox came up.

What might be the cause of this problem? I have literally no idea what's wrong.

If you need code or anything, just ask for it since I don't know what to include in this question.

Thank you.

Here's the code for Window_Initialied

private void Window_Initialized(object sender, EventArgs e)
    {
        MessageBox.Show("asd");

            HandleInstances(); // Checks if multiple instances of the program is running. Exits it if there's more than one instance (tried commenting this out, didn't work)


            if (Properties.Settings.Default.HasRegisteredFiletypes == false) // Checks if theres a need to add the filetypes
                AddExec();

            StartWithMusic(Environment.GetCommandLineArgs().ToList()); // Here I call for the arguments. Checks if there are valid files in the arguments (.mp3, .flac etc)


            SettingsLoadBGs.IsChecked = Properties.Settings.Default.LoadBGs;
            // set accentcolor box

            List<AccentColor> ac = new List<AccentColor>();
            string userAccent = Mplayer.Properties.Settings.Default.Accent.ToLower();
            foreach (Accent c in ThemeManager.DefaultAccents)
            {
                AccentColor acEnt = new AccentColor();
                acEnt.Name = c.Name;
                ac.Add(acEnt);
                if (c.Name.ToLower() == userAccent)
                    ThemeManager.ChangeTheme(this, c, Theme.Dark);
            }
            ThemeManager.IsThemeChanged += new EventHandler<OnThemeChangedEventArgs>(ThemeChanged);

            accentChooserBox.ItemsSource = ac;


    }
Community
  • 1
  • 1
Tokfrans
  • 1,939
  • 2
  • 24
  • 56
  • 1
    Are you handling args in the Main()? Can you post the code? – Stefano Altieri May 08 '14 at 11:39
  • Perhaps your code is assuming that the "working folder" is the same as where the app sits? If so, then the working folder when launched via double-clicking on an MP3 is not going to be the same. Do you have DLLs or other files in the app's folder that perhaps it can't find when launched like this? – Lee Taylor May 08 '14 at 11:42
  • @StefanoAltieri Added the code to the question. – Tokfrans May 08 '14 at 11:45
  • @LeeTaylor That might be it, since I use Directory.GetCurrentDirectory() quite a lot. So from what I understand I have to specify a folder? – Tokfrans May 08 '14 at 11:46
  • The thing is that it never "reaches" the Messagebox at the top even. So all code below that point shouldn't be a problem – Tokfrans May 08 '14 at 11:55
  • Yes, your app should know where it actually is, if not try using a hard-coded string for the time being to establish if it's the issue. – Lee Taylor May 08 '14 at 11:55
  • But you'll have code before that, surely? – Lee Taylor May 08 '14 at 11:56
  • Yes. I will check out some of my classes and see if anything there is acting up. – Tokfrans May 08 '14 at 11:58
  • Did a search through my entire project looking for "GetCurrentDirectory" in class-initializes etc. But I've always used try-catch statements with File.Exists too. So I doubt that will be the problem? – Tokfrans May 08 '14 at 12:03
  • Nevermind my last comment. I replaced all the Directory.GetCurrentDirectory() with hardcoded path to the folder. And the messagebox did come up! But after that it seemed like it stopped again. I'll do some more digging around but I am glad I'm making progress atleast. Thank you – Tokfrans May 08 '14 at 12:11

0 Answers0