V1.1 to Beta 2 - Namespaces Not Recognized

Last post 06-24-2005 1:46 PM by Baiju. 6 replies.

Sort Posts:

  • Hmm [^o)] V1.1 to Beta 2 - Namespaces Not Recognized

    06-23-2005, 10:30 AM
    • Participant
      783 point Participant
    • thermalnoise
    • Member since 06-25-2002, 9:58 AM
    • Georgia
    • Posts 161

    We are attempting to test out a website written in VS2003/.Net 1.1 in VS2005 Beta 2/.Net 2.0.  Our main problem at this point is that certain classes are not being recognized when they are referenced in other files not in the same directory as the class file.

    Example:

    A Framework.cs file under \Applications is inherited by several other webpages. It resides under the namespace Company.WebSite.Applications.

    Another class, SearchHistories, is in \Applications\CrackHistory directory. The namespace of SearchHistories class is Company.WebSite.Applications.CrackHistory. SearchHistories inherits Framework.  Under .NET1.1, there was no problem with this. However, in VS2003, a compile error states "The type or namespace name 'Framework' could not be found (are you missing a using directive or an assembly reference?) C:\WEB\Applications\CrackHistory\SearchHistories.aspx.cs".

    The immediate solution is to copy the Framework.cs file from the Applications directory and copy it into the Applications\CrackHistory directory. Then the error goes away. What is up with that?

    The aim of an argument or discussion should not be victory, but progress. - Joseph Joubert

    If my post has helped you, please "Mark as Answer".
  • Re: V1.1 to Beta 2 - Namespaces Not Recognized

    06-23-2005, 1:01 PM
    • Participant
      1,171 point Participant
    • BradleyB
    • Member since 11-06-2002, 3:53 PM
    • Posts 227
    In VS03 the entire website was compiled into a single assembly.  In VS05 you get an assembly per page or if in batch mode (default) then you get an assembly per folder.  VS05 and ASP.Net 2.0 support the concept of an App_Code folder for common logic.  You should be able to put your Framework.cs into the App_Code folder where all your pages can inherit from.

    Hope this helps, Brad.
  • Re: V1.1 to Beta 2 - Namespaces Not Recognized

    06-23-2005, 1:35 PM
    • Participant
      783 point Participant
    • thermalnoise
    • Member since 06-25-2002, 9:58 AM
    • Georgia
    • Posts 161
    Thanks Brad. That did indeed help me out immensely. One further question: The conversion from 1.1 to 2.0 removed all the control declarations from the code behind. But now it appears I need to put them back in as the .cs file errors now state things like "The name 'lnkPrintFriendly' does not exist in the current context" and points to where I reference the control for properties and the like. So am I supposed to place those control declarations back within the code behind residing in App_Code now?

    Thanks once again. I was getting so frustrated!
    The aim of an argument or discussion should not be victory, but progress. - Joseph Joubert

    If my post has helped you, please "Mark as Answer".
  • Re: V1.1 to Beta 2 - Namespaces Not Recognized

    06-23-2005, 5:08 PM
    • Participant
      990 point Participant
    • Baiju
    • Member since 09-17-2002, 3:07 PM
    • Posts 198
    If Framework.cs is a code-behind file (say page file is framework.aspx)
      you can fix it by adding <%@ reference page = ~/framework.aspx %> to SearchHistories.aspx

    If framework.cs is stand alone code file (I guess not, if it was it would have moved to app_code directory)
     you can fix this problem by adding CodeFileBaseClass = base class name defined in Framework.cs,
    however this may not be supported in beta2 bits.

    We have made changes to our web conversion wizard to fix this kind of problems.

    Baiju
    "This posting is provided "AS IS" with no warranties, and confers no rights"
  • Re: V1.1 to Beta 2 - Namespaces Not Recognized

    06-24-2005, 8:34 AM
    • Participant
      783 point Participant
    • thermalnoise
    • Member since 06-25-2002, 9:58 AM
    • Georgia
    • Posts 161
    This is a different page with a similar setup. RequestForm a page that loads several user controls. Sometimes the user controls will instantiate the RequestForm object to call a public method. The user controls were complaining that RequestForm did not exist, so moving the RequestForm.aspx.cs file to the App_Code folder resolved that issue. Now it is the RequestForm.aspx.cs file that complains the web control references do not exist in the current context. There are compiler errors of two types.

    First, over in the RequestForm.aspx file, which I did not move, this is the directive:
    <%
    @ Page language="c#" Inherits="MERC.AircatWeb.Applications.TO107.RequestForm" CodeFile="..\..\App_Code\Applications\TO107\RequestForm.aspx.cs" %>

    In the RequestForm.aspx.cs file, I have lines like this:

    lnkUploadDiscrepancy.Visible = false;

    The compiler says "The name 'lnkUploadDiscrepancy' does not exist in the current context."

    Second, we also have a 3rd party control on the form, and the compiler gives this error: "'MERC.AircatWeb.Applications.TO107.RequestForm' does not contain a definition for 'RapidSpellWebMultiple1'".  It is declared in a directive in RequestForm.aspx:
    <%@ Register TagPrefix="rapidspellweb" Namespace="Com.Keyoti.RapidSpell" Assembly="Keyoti.RapidSpellWeb" %>

    <RAPIDSPELLWEB:RAPIDSPELLWEBMULTIPLE id="RapidSpellWebMultiple1" runat="server" IgnoreEmptyTextBoxes="False" ShowButton="True"></RAPIDSPELLWEB:RAPIDSPELLWEBMULTIPLE>

    Thanks in advance for the help.

    The aim of an argument or discussion should not be victory, but progress. - Joseph Joubert

    If my post has helped you, please "Mark as Answer".
  • Re: V1.1 to Beta 2 - Namespaces Not Recognized

    06-24-2005, 9:42 AM
    • Participant
      783 point Participant
    • thermalnoise
    • Member since 06-25-2002, 9:58 AM
    • Georgia
    • Posts 161
    I found another posting that solved my problem. Instead of moving the code behind for RequestForm to the App_Code directory, I just needed to add a <%@ Reference Page="~/Applications/TO107/RequestForm.aspx" %> tag to my ascx files.  Now to continue working through the myriad of compiler errors left.  You figure out 1, and 10 more pop up!
    The aim of an argument or discussion should not be victory, but progress. - Joseph Joubert

    If my post has helped you, please "Mark as Answer".
  • Re: V1.1 to Beta 2 - Namespaces Not Recognized

    06-24-2005, 1:46 PM
    • Participant
      990 point Participant
    • Baiju
    • Member since 09-17-2002, 3:07 PM
    • Posts 198
    First of all you donot have to move code-behind files to App_Code directory instead use
    <%@ Reference page/control=<page file name>.

    during compilation.
    Entire app_code directory is built into single assembly. If you move code-behind files to app_code it may not have information about the fileds declared in the aspx/ascx files.
    "This posting is provided "AS IS" with no warranties, and confers no rights"
Page 1 of 1 (7 items)