Web Application Project for Visual Studio 2005 中如何同步页面和 designer.cs 代码

本文介绍在Visual Studio 2005中使用WebApplicationProject时,如何解决外部编辑器修改ASPX文件后导致的设计师文件(.designer.cs)不同步问题。提供了一种简便的方法来重新生成.designer.cs文件。
安装 Web Application Project for Visual Studio 2005 的补丁之后,一个采用 CodeBehind 的 Web 页面通常包含:
A.aspx
A.aspx.resx
A.aspx.cs
A.aspx.designer.cs

这四个文件。

我们知道 .designer.cs 是利用 partial class 特性,由设计器产生的一个文件,用于保存页面中控件的对应定义。如果现在我们在 Visual Studio 之外,用其他编辑器修改了 .aspx 文件,导致其中的控件发生改变,会有什么情况发生?重新用 Visual Studio 打开页面,发现 .designer.cs 里面的代码并不会做自动的更新。
这里我试出来一个办法,可以避免手工去同步。

方法很简单,
1. 删除 .designer.cs
2. 在 Solution Explorer 中,对应的页面上点右键,选择 "Convert to Web Appliaction"

这样就可以让 .designer.cs 文件重新生成一遍了。

转载于:https://www.cnblogs.com/RChen/archive/2006/09/03/493612.html

严重性 代码 说明 项目 文件 行 禁止显示状态 错误 CS0246 未能找到类型或命名空间名“ListBox”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 9 活动 错误 CS0246 未能找到类型或命名空间名“Button”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 6 活动 错误 CS0246 未能找到类型或命名空间名“PictureBox”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 7 活动 错误 CS0246 未能找到类型或命名空间名“Label”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 8 活动 错误 CS0246 未能找到类型或命名空间名“Label”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 10 活动 错误 CS0246 未能找到类型或命名空间名“PictureBox”(是否缺少 using 指令或程序集引用?) QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.Designer.cs 11 活动 错误 CS8957 语言版本 7.3 中的条件表达式无效,因为在“Rectangle”“<null>”之间未找到通用类型。如需使用目标类型转换,请升级到语言版本 9.0 或更高版本。 QRDesigner E:\Visual Studio Project\QR Code v2\QR Code v2\QR Code v2\MainForm.cs 69 活动 给出修改后的完整代码
最新发布
10-12
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> <PropertyGroup> <ProjectType>local</ProjectType> <ProjectVersion>7.10.377</ProjectVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{ADC5A455-0A27-4553-B7AA-BF869BCD8EB1}</ProjectGuid> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <AssemblyName>LinuxCmd</AssemblyName> <OutputType>WinExe</OutputType> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <IsWebBootstrapper>false</IsWebBootstrapper> <PublishUrl>publish\</PublishUrl> <Install>true</Install> <InstallFrom>Disk</InstallFrom> <UpdateEnabled>false</UpdateEnabled> <UpdateMode>Foreground</UpdateMode> <UpdateInterval>7</UpdateInterval> <UpdateIntervalUnits>Days</UpdateIntervalUnits> <UpdatePeriodically>false</UpdatePeriodically> <UpdateRequired>false</UpdateRequired> <MapFileExtensions>true</MapFileExtensions> <ApplicationRevision>0</ApplicationRevision> <ApplicationVersion>1.0.0.%2a</ApplicationVersion> <UseApplicationTrust>false</UseApplicationTrust> <BootstrapperEnabled>true</BootstrapperEnabled> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PlatformTarget>x86</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PlatformTarget>x86</PlatformTarget> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup> <StartupObject>LinuxCmd.Program</StartupObject> </PropertyGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ItemGroup> <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> <EmbeddedResource Include="LinuxCmd\frMain.resx"> <DependentUpon>frMain.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> <Reference Include="NAudio, Version=1.7.2.19, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>.\NAudio.dll</HintPath> </Reference> <Reference Include="SDK, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>.\SDK.dll</HintPath> </Reference> <Reference Include="System.Windows.Forms" /> <Reference Include="System" /> <Reference Include="System.Drawing" /> <Compile Include="AssemblyInfo.cs" /> <Compile Include="Global.cs" /> <Compile Include="LinuxCmd\LinuxEvent.cs" /> <Compile Include="LinuxCmd\BluetoothScanEvent.cs" /> <Compile Include="LinuxCmd\frMain.cs"> <SubType>Form</SubType> </Compile> <Compile Include="LinuxCmd\LinuxUdp.cs" /> <Compile Include="LinuxCmd\PlayController.cs" /> <Compile Include="LinuxCmd\Properties\Resources.cs" /> <Compile Include="LinuxCmd\DevItem.cs" /> <Compile Include="LinuxCmd\AudioEvent.cs" /> <Compile Include="LinuxCmd\RTPManager.cs" /> <Compile Include="LinuxCmd\WaveRecordDataHandler.cs" /> <Compile Include="LinuxCmd\RecordController.cs" /> <Compile Include="LinuxCmd\WaveRecorder.cs" /> <Compile Include="LinuxCmd\WaveErrorEventHandler.cs" /> <Compile Include="LinuxCmd\ATClient.cs" /> <Compile Include="LinuxCmd\LinuxSendSocket.cs" /> <Compile Include="LinuxCmd\Program.cs" /> <Compile Include="LinuxCmd\AudioManager.cs" /> <Compile Include="LinuxCmd\UdpBrocast.cs" /> <Compile Include="LinuxCmd\Properties\Settings.cs" /> <EmbeddedResource Include="LinuxCmd.Properties.Resources.resources" /> <EmbeddedResource Include="LinuxCmd.frMain.resources" /> </ItemGroup> <ItemGroup> <Content Include="LinuxCmd.ini"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> <ItemGroup> <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> <Visible>False</Visible> <ProductName>.NET Framework 3.5 SP1</ProductName> <Install>true</Install> </BootstrapperPackage> </ItemGroup> </Project>
07-11
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值