ASP.NET on Mono 4.0 - Objects Not Found

pethog

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

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. The application builds and runs successfully on Windows using VS 2012 on Windows 8.1 .

I was able to port the application over to Linux, but am having problems building and running the application in 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).

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. An example of one of these pages (the login page) is below :

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

    <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

MonoDevelop Environment Errors (Unfortunately I don't have enough Rep to post an image):

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

    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?

pethog

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. Upon build, the *.aspx.designer.cs file was autogenerated by the Mono 4.0 Runtime and it builds correctly.

Thanks again for all the help!

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

FormsAuthentication on mono/ASP.NET?

분류에서Dev

Auth0, Angular 4 및 ASP.NET Core

분류에서Dev

MONO / .NET 4-Google SMTP를 사용하여 페이지에서 이메일을 보내는 ASP.NET

분류에서Dev

NHibernate on Mono running ASP.NET MVC 3 web application

분류에서Dev

Mono ASP.Net MVC EntityFramework 예외

분류에서Dev

Why is no package 'mono' found?

분류에서Dev

ASP.NET Boilerplate Module 0을 IdentityServer4와 통합

분류에서Dev

Asp.Net MVC Model Binding to a property type System.Uri got issues with Mono

분류에서Dev

asp.net 4.5를 지원하려면 최신 버전의 mono xsp4를 우분투에 설치하십시오.

분류에서Dev

ASP.NET MVC 4의 ViewComponent

분류에서Dev

DataTables Asp.Net MVC 4 Process

분류에서Dev

ASP.NET MVC4 ActionFilters

분류에서Dev

MVC 4 ASP.NET 구성

분류에서Dev

ASP.NET MVC 4의 RegisterRoutes

분류에서Dev

How to JSON deserialize child objects ASP.NET Core

분류에서Dev

Unexpected results, Parse Array of JSON Objects in ASP.Net

분류에서Dev

ASP.NET Web Forms에 대한 Mono의 지원은 어떻게 될까요?

분류에서Dev

Lighttpd의 Mono FastCGI는 내 ASP.NET 응답을 확장합니다.

분류에서Dev

mono asp.net 웹 서비스에서 어셈블리를 찾을 수 없음

분류에서Dev

jQuery Dialog hover thumbnails using ASP.NET MVC 4

분류에서Dev

ASP.NET MVC 4 사용자 인증

분류에서Dev

ASP.NET MVC 4 사용자 인증

분류에서Dev

Calling ASP.NET MVC 4 Controller from Javascript

분류에서Dev

ASP.NET MVC 4의 전역 변수

분류에서Dev

TinyMCE Asp.NET 4 아이콘 누락

분류에서Dev

Can't add scripts in bundle (asp.net mvc 4)

분류에서Dev

TinyMCE Asp.NET 4 아이콘 누락

분류에서Dev

ASP.NET MVC 4 사용자 인증

분류에서Dev

ASP.NET mvc4 DropDownListFor pass back an object

Related 관련 기사

뜨겁다태그

보관