简体   繁体   English

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

[英]ASP.NET on Mono 4.0 - Objects Not Found

I am fairly new to ASP.NET and am having issues getting the IDs for ASP objects in the *.aspx files to be detected by the C# files inheriting the page (the associated *.aspx.cs files). 我对ASP.NET相当陌生,并且在获取* .aspx文件中ASP对象的ID时遇到问题,这些ID由继承页面的C#文件(关联的* .aspx.cs文件)检测到。

For some context, I have been tasked with migrating an ASP.NET website from an IIS Server on a Windows Server 2008 R2 instance to CentOS using Mono. 在某些情况下,我的任务是使用Mono将ASP.NET网站从Windows Server 2008 R2实例上的IIS服务器迁移到CentOS。 The application builds and runs successfully on Windows using VS 2012 on Windows 8.1 . 该应用程序可在Windows 8.1上使用VS 2012在Windows上成功构建并运行。

I was able to port the application over to Linux, but am having problems building and running the application in MonoDevelop. 我能够将应用程序移植到Linux,但是在MonoDevelop中构建和运行应用程序时遇到了问题。 I am working on CentOS 7 with Mono 4.0 and MonoDevelop 5.9 with the application being an ASP .NET Application (not an ASP .NET MVC Application). 我正在使用Mono 4.0和MonoDevelop 5.9的CentOS 7,该应用程序是ASP .NET应用程序(不是ASP .NET MVC应用程序)。

After loading and staging the project files and assemblies into a native MonoDevelop ASP .NET Application project, I received the following errors for several of the object variable IDs referenced in the *.aspx.cs files, but declared in the *.aspx files. 将项目文件和程序集加载并暂存到本机MonoDevelop ASP .NET Application项目中后,对于* .aspx.cs文件中引用但在* .aspx文件中声明的一些对象变量ID,我收到以下错误。 An example of one of these pages (the login page) is below : 这些页面之一(登录页面)的示例如下:

login.aspx.cs : 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>";
             }
        }
    }

login.aspx (important parts): 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>

EDIT Added per @Misters ( https://stackoverflow.com/users/1874460/misters ) request 编辑每个@Misters( https://stackoverflow.com/users/1874460/misters )请求添加

MonoDevelop Environment Errors (Unfortunately I don't have enough Rep to post an image): MonoDevelop环境错误(很遗憾,我没有足够的代表来发布图像):

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

My thought was to add placeholder variables in the *.aspx.cs code to get it to build, which worked for the build process: 我的想法是在* .aspx.cs代码中添加占位符变量以进行构建,该变量可用于构建过程:

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

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

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

However, at run-time I received the following error: 但是,在运行时我收到以下错误:

    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

Compiler Command Line Log: 编译器命令行日志:

    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)

Is there a better method which I should be using to get the ASP object variable IDs to be detected by the C# script? 我应该使用一种更好的方法来获取C#脚本检测到的ASP对象变量ID吗?

Thanks Matt! 谢谢马特! ( https://stackoverflow.com/users/268874/matt-ward ) I copied the code from the old *.aspx and *aspx.cs files into a new 'Web Form with Code Behind' file with the same name and staged in the same location as the original. https://stackoverflow.com/users/268874/matt-ward )我将代码从旧的* .aspx和* aspx.cs文件复制到了具有相同名称的新的“带有代码隐藏的Web表单”文件中,并暂存与原始位置相同。 Upon build, the *.aspx.designer.cs file was autogenerated by the Mono 4.0 Runtime and it builds correctly. 生成后,*。aspx.designer.cs文件由Mono 4.0 Runtime自动生成,并且可以正确生成。

Thanks again for all the help! 再次感谢您提供的所有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM