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.
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.