質問

myFormという新しいフォームを作成すると、myForm.hの上部は次のようになります。

#pragma once

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;     //<<<< THIS ONE
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

素晴らしいフォームデザイナーは常にオブジェクトを完全に修飾するため、これらのどれも必要ありません。

この1つでマークされたものは、ビルドを壊すので特に迷惑です。これは、IListの汎用形式をあらゆる場所で使用しているためです。非常に気に入っているため、stdafx.hに次のように配置します。

using System::Collections::Generic::IList;

したがって、次のように、IListを使用する他のファイルからmyFormを使用する場合:

#include "StdAfx.h"
#include "ABC.h"
#include "myForm.h"

ABC::ABC()
{
    IList<int>^ myList;
    ...
}

その後、コンパイルに失敗します:

1>.\ABC.cpp(7) : error C2872: 'IList' : ambiguous symbol
1>        could be 'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Collections::Generic::IList'
1>        or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Collections::IList'
1>.\ABC.cpp(7) : error C2872: 'IList' : ambiguous symbol
1>        could be 'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Collections::Generic::IList'
1>        or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Collections::IList'

では、新しいフォームがこれらすべての役に立たない破壊的な使用を追加するのを止めるにはどうすればよいですか

役に立ちましたか?

解決

使用する特定の言語のItemTemplatesディレクトリにあるzipファイルを編集することにより、Visual Studioが使用するデフォルトのテンプレートを変更できます。

C:\ Program Files \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ItemTemplates \ CSharp \ Code \ 1033

は、C#テンプレートの場所です。 C ++テンプレートは同様のディレクトリにあると想定していますが、VSインスタンスがC ++でインストールされていないので便利です。

他のヒント

Visual Studioのフォームテンプレートを変更できます。さらに読むには、次を参照してください。

http://msdn.microsoft.com/ en-us / library / ms185319(VS.80).aspx

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top