【问题标题】:Invalid Deployment Exception无效部署异常
【发布时间】:2012-09-20 09:26:56
【问题描述】:

在创建新类实例时,我得到“System.Deployment.dll 中发生‘System.Deployment.Application.InvalidDeploymentException’类型的第一次机会异常”。

它发生在:

PrinterSettings^ MyPS = gcnew PrinterSettings();

一切正常,我得到了我想要的价值。

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());
}

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

有什么想法吗?谢谢。

【问题讨论】:

    标签: c++ .net visual-studio-2010


    【解决方案1】:

    这是一个“第一次机会”异常,这意味着调试器观察到一个可以处理的异常被抛出。在这种情况下,应用程序可能会尝试确定应用程序的安装方式,例如通过 ClickOnce,以确定您的用户应用程序路径是什么。

    请参阅What causes an InvalidDeploymentException in a WPF application? 以获得很好的解释。

    【讨论】:

    • 所以我尝试获取一个仅在未来(部署后)才知道的值?这是否意味着我与它无关?谢谢你。编辑:我知道这只是一个调试问题。
    • @Nikonation 如果这只是第一次机会例外,用户将永远不会看到它。假设没有其他问题,你应该没问题。
    猜你喜欢
    • 1970-01-01
    • 2014-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 2018-04-30
    • 2013-10-07
    • 1970-01-01
    相关资源
    最近更新 更多