ASP.NET 在 Mono 4.0 上 - 未找到对象

ASP.NET on Mono 4.0 - Objects Not Found

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

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

上成功构建并 运行s

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

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

登录。aspx.cs:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class ILSecure_login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
         protected void LoginButton_Click(object sender, EventArgs e)
         {
             if (FormsAuthentication.Authenticate(this.UserName.Text.Trim(), this.Password.Text.Trim()))
             {
                 FormsAuthentication.RedirectFromLoginPage(this.UserName.Text.Trim(), false);
             }
             else
             {
                 this.FailureText.Text = "Incorrect username or password.<br><b>Please re-enter your credentials.</b>";
             }
        }
    }

login.aspx(重要部分):

    <table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">
    ...
        <tr>
            <td align="right" bgcolor="#f5f8fb">
                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label></td>
            <td bgcolor="#f5f8fb" style="width: 168px">
                <asp:TextBox ID="UserName" runat="server" BorderStyle="Solid"></asp:TextBox>
                <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                        ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>                                  </td>
        </tr>
    ...
        <tr>
            <td align="right" bgcolor="#f5f8fb">
                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label></td>
            <td bgcolor="#f5f8fb" style="width: 168px">
                <asp:TextBox ID="Password" runat="server" TextMode="Password" BorderStyle="Solid"></asp:TextBox>
                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>                                  </td>
        </tr>
    ...
        <tr>
            <td colspan="2" align="center" bgcolor="#f5f8fb" style="color: red">
                <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal></td>
        </tr>
        <tr>
            <td colspan="2" align="center" valign="middle" bgcolor="#ebf1f7" style="height: 32px">
                <asp:Button ID="LoginButton" runat="server" CommandName="Login" OnClick="LoginButton_Click"
                                        Text="Log In" ValidationGroup="Login1" BackColor="#E0E0E0" ForeColor="Black" BorderStyle="Solid" /></td>
        </tr>
    </table>

编辑 根据@Misters ( https://whosebug.com/users/1874460/misters ) 请求添加

MonoDevelop 环境错误(遗憾的是我没有足够的 Rep 来 post 图片):

    /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)

我的想法是在 *.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

编译器命令行日志:

    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)

我是否应该使用更好的方法来获取要由 C# 脚本检测的 ASP 对象变量 ID?

谢谢马特! ( https://whosebug.com/users/268874/matt-ward ) 我将旧的 *.aspx 和 *aspx.cs 文件中的代码复制到一个新的 'Web Form with Code Behind' 文件中,该文件同名并存放在与原始文件相同的位置。构建时,*.aspx.designer.cs 文件由 Mono 4.0 运行时自动生成,并且构建正确。

再次感谢大家的帮助!