C# Mono 4.0上的ASP.NET-找不到对象

C# Mono 4.0上的ASP.NET-找不到对象,c#,asp.net,.net,mono,monodevelop,C#,Asp.net,.net,Mono,Monodevelop,我是ASP.NET新手,在获取*.aspx文件中ASP对象的ID时遇到问题,该ID将由继承该页面的C#文件(关联的*.aspx.cs文件)检测 在某些情况下,我的任务是使用Mono将ASP.NET网站从Windows Server 2008 R2实例上的IIS服务器迁移到CentOS。该应用程序在Windows 8.1上使用VS 2012在Windows上成功构建和运行 我能够将应用程序移植到Linux,但在MonoDevelop中构建和运行应用程序时遇到问题。我正在使用Mono4.0和Mono

我是ASP.NET新手,在获取*.aspx文件中ASP对象的ID时遇到问题,该ID将由继承该页面的C#文件(关联的*.aspx.cs文件)检测

在某些情况下,我的任务是使用Mono将ASP.NET网站从Windows Server 2008 R2实例上的IIS服务器迁移到CentOS。该应用程序在Windows 8.1上使用VS 2012在Windows上成功构建和运行

我能够将应用程序移植到Linux,但在MonoDevelop中构建和运行应用程序时遇到问题。我正在使用Mono4.0和MonoDevelop 5.9开发CentOS 7,应用程序是ASP.NET应用程序(不是ASP.NETMVC应用程序)

在将项目文件和程序集加载并暂存到本机MonoDevelop ASP.NET应用程序项目中之后,我收到了以下关于*.aspx.cs文件中引用但在*.aspx文件中声明的几个对象变量ID的错误。以下是其中一个页面(登录页面)的示例:

login.aspx.cs:

我的想法是在*.aspx.cs代码中添加占位符变量,以使其进行构建,这对构建过程有效:

    protected System.Web.UI.WebControls.Label UserName;

    protected System.Web.UI.WebControls.Label Password;

    protected System.Web.UI.WebControls.Literal FailureText;
但是,在运行时,我收到以下错误:

    System.Web.Compilation.CompilationException

    CS0102: The type `ILSecure_Management' already contains a definition for `displayCredentials'

    Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

    Details: CS0102: The type `ILSecure_Management' already contains a definition for `displayCredentials'

    Error origin: Compiler

    Error source file: /root/intellilock/intellilock/licensemanagement/Management.aspx

    Exception stack trace:
    at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00365] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:853
    at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:731
    at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00264] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:826
    at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:451
    Error source context:
    Error lines: 23, 48, 60, 69

    21: <form id="form1" runat="server">
    22: <div align="center">
    23: <div align="right"><asp:Label ID="displayCredentials" runat="server" Font-Size="8pt" Font-Names="Arial"></asp:Label>
    24: &nbsp;</div> 25: <span class="style4">License Management<br />
    Full error source code: (click to show): <See Above>
    Compiler command line (click to show):
    //<See Below>
    Version Information: 4.0.1 (tarball Sun May 17 07:06:24 UTC 2015); ASP.NET Version: 4.0.30319.17020
有没有更好的方法可以让C脚本检测ASP对象变量ID?

谢谢Matt!()我将代码从旧的*.aspx和*.aspx.cs文件复制到一个新的“带有代码隐藏的Web表单”文件中,该文件具有相同的名称,并与原始文件放在相同的位置。生成时,*.aspx.designer.cs文件由Mono 4.0运行时自动生成,并正确生成


再次感谢您的帮助

我在任何地方都看不到NullReferenceException。当您保存.aspx文件时,MonoDevelop将自动生成一个.designer.cs文件,该文件将包含生成的代码,其中包含您在.aspx文件中指定名称的每个web控件的变量。@先生:谢谢!我用错误更新了帖子,以表明问题所在。@MattWard工作得很有魅力。我能够将代码复制到一个新文件中,并在删除依赖项后正确构建它。谢谢
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(40,40): Error CS0103: The name `UserName' does not exist in the current context (CS0103) (intellilock)
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(62,62): Error CS0103: The name `Password' does not exist in the current context (CS0103) (intellilock)
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(46,46): Error CS0103: The name `UserName' does not exist in the current context (CS0103) (intellilock)
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(14,14): Error CS0103: The name `FailureText' does not exist in the current context (CS0103) (intellilock)
    protected System.Web.UI.WebControls.Label UserName;

    protected System.Web.UI.WebControls.Label Password;

    protected System.Web.UI.WebControls.Literal FailureText;
    System.Web.Compilation.CompilationException

    CS0102: The type `ILSecure_Management' already contains a definition for `displayCredentials'

    Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

    Details: CS0102: The type `ILSecure_Management' already contains a definition for `displayCredentials'

    Error origin: Compiler

    Error source file: /root/intellilock/intellilock/licensemanagement/Management.aspx

    Exception stack trace:
    at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00365] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:853
    at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:731
    at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00264] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:826
    at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /home/abuild/rpmbuild/BUILD/mono-4.0.1/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:451
    Error source context:
    Error lines: 23, 48, 60, 69

    21: <form id="form1" runat="server">
    22: <div align="center">
    23: <div align="right"><asp:Label ID="displayCredentials" runat="server" Font-Size="8pt" Font-Names="Arial"></asp:Label>
    24: &nbsp;</div> 25: <span class="style4">License Management<br />
    Full error source code: (click to show): <See Above>
    Compiler command line (click to show):
    //<See Below>
    Version Information: 4.0.1 (tarball Sun May 17 07:06:24 UTC 2015); ASP.NET Version: 4.0.30319.17020
    mcs /target:library /lib:"/root/intellilock/intellilock/bin" /debug+ /optimize- /warn:4 /out:"/tmp/root-temp-aspnet-0/7c9c93f5/App_Web_51303f48.dll" /r:"/opt/mono/lib/mono/gac/Microsoft.CSharp/4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll" /r:"/opt/mono/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll" /r:"/opt/mono/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll" /r:"/opt/mono/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll" /r:"/opt/mono/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll" /r:"/opt/mono/lib/mono/gac/System.Web.Services/4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll" /r:"/opt/mono/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll" /r:"/opt/mono/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll" /r:"/opt/mono/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll" /r:"/opt/mono/lib/mono/gac/System.IdentityModel/4.0.0.0__b77a5c561934e089/System.IdentityModel.dll" /r:"/opt/mono/lib/mono/gac/System.Runtime.Serialization/4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll" /r:"/opt/mono/lib/mono/gac/System.Xaml/4.0.0.0__b77a5c561934e089/System.Xaml.dll" /r:"/opt/mono/lib/mono/gac/System.ServiceModel/4.0.0.0__b77a5c561934e089/System.ServiceModel.dll" /r:"/opt/mono/lib/mono/gac/System.ServiceModel.Web/4.0.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll" /r:"/opt/mono/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll" /r:"/opt/mono/lib/mono/gac/System.Web.Extensions/4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll" /r:"/opt/mono/lib/mono/gac/System.Data.DataSetExtensions/4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll" /r:"/opt/mono/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll" /r:"/opt/mono/lib/mono/gac/System.ComponentModel.DataAnnotations/4.0.0.0__31bf3856ad364e35/System.ComponentModel.DataAnnotations.dll" /r:"/opt/mono/lib/mono/gac/System.Web.DynamicData/4.0.0.0__31bf3856ad364e35/System.Web.DynamicData.dll" /r:"/opt/mono/lib/mono/gac/System.Data.Linq/4.0.0.0__b77a5c561934e089/System.Data.Linq.dll" /r:"/opt/mono/lib/mono/gac/System.Web.ApplicationServices/4.0.0.0__31bf3856ad364e35/System.Web.ApplicationServices.dll" /r:"/opt/mono/lib/mono/gac/System.Design/4.0.0.0__b03f5f7f11d50a3a/System.Design.dll" /r:"/opt/mono/lib/mono/gac/System.Windows.Forms/4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll" /r:"/root/intellilock/intellilock/bin/System.Data.SQLite.dll" /r:"/root/intellilock/intellilock/bin/IntelliLockDB.dll" /r:"/root/intellilock/intellilock/bin/IntelliLock.LicenseManager.dll" /r:"/root/intellilock/intellilock/bin/KMobile.Web.dll" /r:"/root/intellilock/intellilock/bin/intellilock.dll" /r:"/tmp/root-temp-aspnet-0/7c9c93f5/App_global.asax_62fd6eef.dll" /nowarn:0169 /d:DEBUG /noconfig /sdk:4.5 -- "/tmp/root-temp-aspnet-0/7c9c93f5/App_Web_51303f48_0.cs" "/tmp/root-temp-aspnet-0/7c9c93f5/App_Web_51303f48_1.cs" "/tmp/root-temp-aspnet-0/7c9c93f5/App_Web_51303f48_2.cs" "/tmp/root-temp-aspnet-0/7c9c93f5/App_Web_51303f48_3.cs" 

    /root/intellilock/intellilock/licensemanagement/Management.aspx(23,55): error CS0102: The type `ILSecure_Management' already contains a definition for `displayCredentials'
    /root/intellilock/intellilock/licensemanagement/Management.aspx.cs(15,44): (Location of the symbol related to previous error)
    /root/intellilock/intellilock/licensemanagement/login.aspx(48,57): error CS0102: The type `ILSecure_login' already contains a definition for `UserName'
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(14,41): (Location of the symbol related to previous error)
    /root/intellilock/intellilock/licensemanagement/login.aspx(60,57): error CS0102: The type `ILSecure_login' already contains a definition for `Password'
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(16,41): (Location of the symbol related to previous error)
    /root/intellilock/intellilock/licensemanagement/login.aspx(69,57): error CS0102: The type `ILSecure_login' already contains a definition for `FailureText'
    /root/intellilock/intellilock/licensemanagement/login.aspx.cs(18,43): (Location of the symbol related to previous error)