创建新的类实例时,我得到“System.Deployment.dll 中发生'System.Deployment.Application.InvalidDeploymentException' 类型的第一次机会异常”。
它发生在:
PrinterSettings^ MyPS = gcnew PrinterSettings();
一切正常,我得到了我想要的价值。
表格1.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());
}
打印.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
有什么想法吗?谢谢你。