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

本文关键字:对象 NET 上的 Mono ASP | 更新日期: 2023-09-27 17:51:07

我对ASP相当陌生。. NET和我在*中获得ASP对象的id有问题。由继承该页的c#文件(关联的*.aspx.cs文件)检测。

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

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

在将项目文件和程序集加载到原生MonoDevelop ASP . net应用程序项目中并登台之后,我收到了以下错误,因为在*.aspx.cs文件中引用的几个对象变量id,但在*. js文件中声明。aspx文件。下面是其中一个页面(登录页面)的示例:

<我> login.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>";
             }
        }
    }

<我>登录。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>

EDIT根据@Misters (https://stackoverflow.com/users/1874460/misters)请求添加

MonoDevelop环境错误(不幸的是,我没有足够的Rep来发布图像):

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

是否有一个更好的方法,我应该用它来获得ASP对象变量id由c#脚本检测?

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

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

再次感谢所有的帮助!