1

新しいクラスインスタンスを作成すると、「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());
}

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

何が起こっているのかアイデアはありますか?ありがとうございました。

4

1 に答える 1

0

これは「ファーストチャンス」例外です。つまり、デバッガーは、処理される可能性のある例外がスローされたことを確認します。この場合、アプリケーションは、ClickOnceなどを介してアプリがどのようにインストールされているかを判断し、ユーザーアプリのパスを判断しようとしている可能性があります。

WPFアプリケーションでInvalidDeploymentExceptionが発生する原因を参照してください。良い説明のために。

于 2012-09-20T11:54:02.563 に答える