vs2005 - vc ++ - 无法为此文件显示设计器,因为其中的所有类都无法设计

时间:2012-08-29 14:46:46

标签: visual-c++ visual-studio-2005 gui-designer

我知道之前已经多次询问过这个话题,但似乎没有一个问题可以解决我的问题。我需要创建一个Windows窗体应用程序(在visual studio 2005,32位),我需要使用makefile构建。我只是从创建一个Windows窗体应用程序开始,然后将“properties-> General-> Configuration Type”更改为“Makefile”。然后我添加一个简单的makefile,几乎什么都不做。问题是当我这样做时,设计师不再工作了。文件的内容是:

form1.h:

#pragma once
namespace design {
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
        }
    protected:
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private:
        System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
        void InitializeComponent(void)
        {
            this->components = gcnew System::ComponentModel::Container();
            this->Size = System::Drawing::Size(300,300);
            this->Text = L"Form1";
            this->Padding = System::Windows::Forms::Padding(0);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        }
#pragma endregion
    };
}

主文件(design.cpp):

// design.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace design;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 
    // Create the main window and run it
    Application::Run(gcnew Form1());
    return 0;
}

make file(design.mak):

all: clean 
clean:
    @echo Clean
    if exist *.obj erase *.obj
    @echo Clean done!

项目文件(design.vcproj):

<?xml version="1.0" encoding="windows-1254"?>
<VisualStudioProject
    ProjectType="Visual C++"
    Version="8,00"
    Name="design"
    ProjectGUID="{2652A3E3-D3B2-48F0-8C9C-831BF4912839}"
    RootNamespace="design"
    Keyword="MakeFileProj"
    >
    <Platforms>
        <Platform
            Name="Win32"
        />
    </Platforms>
    <ToolFiles>
    </ToolFiles>
    <Configurations>
        <Configuration
            Name="Debug|Win32"
            OutputDirectory="$(SolutionDir)$(ConfigurationName)"
            IntermediateDirectory="$(ConfigurationName)"
            ConfigurationType="0"
            CharacterSet="1"
            ManagedExtensions="2"
            >
            <Tool
                Name="VCNMakeTool"
                BuildCommandLine=""
                ReBuildCommandLine=""
                CleanCommandLine=""
                Output=""
                PreprocessorDefinitions=""
                IncludeSearchPath=""
                ForcedIncludes=""
                AssemblySearchPath=""
                ForcedUsingAssemblies=""
                CompileAsManaged=""
            />
        </Configuration>
        <Configuration
            Name="Release|Win32"
            OutputDirectory="$(SolutionDir)$(ConfigurationName)"
            IntermediateDirectory="$(ConfigurationName)"
            ConfigurationType="1"
            CharacterSet="1"
            ManagedExtensions="2"
            WholeProgramOptimization="1"
            >
            <Tool
                Name="VCPreBuildEventTool"
            />
            <Tool
                Name="VCCustomBuildTool"
            />
            <Tool
                Name="VCXMLDataGeneratorTool"
            />
            <Tool
                Name="VCWebServiceProxyGeneratorTool"
            />
            <Tool
                Name="VCMIDLTool"
            />
            <Tool
                Name="VCCLCompilerTool"
                PreprocessorDefinitions="WIN32;NDEBUG"
                RuntimeLibrary="2"
                UsePrecompiledHeader="2"
                WarningLevel="3"
                DebugInformationFormat="3"
            />
            <Tool
                Name="VCManagedResourceCompilerTool"
            />
            <Tool
                Name="VCResourceCompilerTool"
            />
            <Tool
                Name="VCPreLinkEventTool"
            />
            <Tool
                Name="VCLinkerTool"
                AdditionalDependencies="$(NoInherit)"
                LinkIncremental="1"
                GenerateDebugInformation="true"
                SubSystem="2"
                EntryPointSymbol="main"
                TargetMachine="1"
            />
            <Tool
                Name="VCALinkTool"
            />
            <Tool
                Name="VCManifestTool"
            />
            <Tool
                Name="VCXDCMakeTool"
            />
            <Tool
                Name="VCBscMakeTool"
            />
            <Tool
                Name="VCFxCopTool"
            />
            <Tool
                Name="VCAppVerifierTool"
            />
            <Tool
                Name="VCWebDeploymentTool"
            />
            <Tool
                Name="VCPostBuildEventTool"
            />
        </Configuration>
    </Configurations>
    <References>
        <AssemblyReference
            RelativePath="System.dll"
            AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
        />
        <AssemblyReference
            RelativePath="System.Data.dll"
            AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
        />
        <AssemblyReference
            RelativePath="System.Drawing.dll"
            AssemblyName="System.Drawing, Version=2.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
        />
        <AssemblyReference
            RelativePath="System.Windows.Forms.dll"
            AssemblyName="System.Windows.Forms, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
        />
        <AssemblyReference
            RelativePath="System.XML.dll"
            AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
        />
    </References>
    <Files>
        <Filter
            Name="Source Files"
            Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
            UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
            >
            <File
                RelativePath=".\AssemblyInfo.cpp"
                >
            </File>
            <File
                RelativePath=".\design.cpp"
                >
            </File>
            <File
                RelativePath=".\stdafx.cpp"
                >
                <FileConfiguration
                    Name="Release|Win32"
                    >
                    <Tool
                        Name="VCCLCompilerTool"
                        UsePrecompiledHeader="1"
                    />
                </FileConfiguration>
            </File>
        </Filter>
        <Filter
            Name="Header Files"
            Filter="h;hpp;hxx;hm;inl;inc;xsd"
            UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
            >
            <File
                RelativePath=".\Form1.h"
                FileType="3"
                >
                <File
                    RelativePath=".\Form1.resX"
                    SubType="Designer"
                    >
                </File>
            </File>
            <File
                RelativePath=".\resource.h"
                >
            </File>
            <File
                RelativePath=".\stdafx.h"
                >
            </File>
        </Filter>
        <Filter
            Name="Resource Files"
            Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
            UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
            >
            <File
                RelativePath=".\app.ico"
                >
            </File>
            <File
                RelativePath=".\app.rc"
                >
            </File>
        </Filter>
        <Filter
            Name="Make Files"
            >
            <File
                RelativePath=".\design.mak"
                >
            </File>
        </Filter>
        <File
            RelativePath=".\ReadMe.txt"
            >
        </File>
    </Files>
    <Globals>
    </Globals>
</VisualStudioProject>

解决方案文件(design.sln):

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "design", "design.vcproj", "{2652A3E3-D3B2-48F0-8C9C-831BF4912839}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Win32 = Debug|Win32
        Release|Win32 = Release|Win32
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {2652A3E3-D3B2-48F0-8C9C-831BF4912839}.Debug|Win32.ActiveCfg = Debug|Win32
        {2652A3E3-D3B2-48F0-8C9C-831BF4912839}.Debug|Win32.Build.0 = Debug|Win32
        {2652A3E3-D3B2-48F0-8C9C-831BF4912839}.Release|Win32.ActiveCfg = Release|Win32
        {2652A3E3-D3B2-48F0-8C9C-831BF4912839}.Release|Win32.Build.0 = Release|Win32
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
EndGlobal

我知道makefile没有做任何事情(它也不适用于合理的makefile),但在这种情况下我不关心构建操作。我做的唯一更改是更改“配置类型”属性并将.vcproj文件中的“关键字”属性更改为Keyword =“MakeFileProj”。 (构建不起作用吗?!)。我真的被困在这里,寻找任何有用的想法。

谢谢,

Seleciii44

2 个答案:

答案 0 :(得分:0)

您无需将项目转换为Makefile类型。可以从批处理文件或makefile的命令行构建任何Visual Studio项目。请参阅此参考:http://msdn.microsoft.com/en-us/library/xee0c8y7%28v=vs.80%29.aspx

您需要使用/ Build开关。例子:

devenv foo.csproj /Build "Release"
devenv foo.vcproj /Build "Debug"

答案 1 :(得分:0)

终于找到了解决方案。问题出在“属性 - > NMake-&gt; IntelliSense-&gt;公共语言运行时支持”选项中。我将它从“无公共语言运行时支持”改为“公共语言运行时支持”,现在可以使用了。