1

When creating new class instance I get "A first chance exception of type 'System.Deployment.Application.InvalidDeploymentException' occurred in System.Deployment.dll".

It happens at:

PrinterSettings^ MyPS = gcnew PrinterSettings();

Everything works fine and I get a value I want.

Form1.cpp:

#include "stdafx.h"
#include "Form1.h"
#include "Print.h"
#include <iostream>

System::Void DPrint::Form1::Form1_Load(System::Object^  sender, System::EventArgs^  e)
{
    PrinterSettings^ MyPS = gcnew PrinterSettings();
    System::Windows::Forms::MessageBox::Show("From Class PrinterSettings: " + MyPS->IniFilePath());
}

Print.h:

#ifndef PRINT_H
#define PRINT_H

public ref class PrinterSettings
{
private:
    System::String^ m_strPath;


public:
    PrinterSettings()
    {
        m_strPath = System::Windows::Forms::Application::UserAppDataPath;
    }

    System::String^ IniFilePath() { return m_strPath; };

};
#endif

Any ideas what is going on? Thank you.

Nikonation
  • 23
  • 7

1 Answers1

0

This is a "first chance" exception, meaning the debugger observes an exception is thrown that may be handled. In this case, it is likely the application is trying to determine how the app is installed, such as via ClickOnce, to determine what your User app path is.

See What causes an InvalidDeploymentException in a WPF application? for a good explanation.

Community
  • 1
  • 1
akton
  • 14,148
  • 3
  • 43
  • 47
  • So I try to get a value which will be known in the future (after deployment) only? Does it mean I have nothing to do with it? Thank you. edit: I understand this is a debug issue only. – Nikonation Sep 20 '12 at 12:10
  • @Nikonation If it is only a first chance exception, users will never see it. Assuming there are no other issues, you should be fine. – akton Sep 20 '12 at 12:13