Command Line Compilation - Inherits

Discussion in 'ASP .Net' started by Todd A, Feb 26, 2004.

  1. Todd A

    Todd A Guest

    If I use the following in my code behind page:

    Public Class _Default
    Inherits System.Web.UI.Page

    The page will compile with no errors from the command line compiler
    (vbc.exe)

    But, If I insert my own base page to inherit from, say,

    Public Class _Default
    Inherits BaseWebPage

    I am unable to get the code to compile, even if I compile BaseWebPage first
    and make a reference to it.
    Do I have to include the code for BaseWebPage with every page that wants to
    inherit it?
    I've tried a number of things here, but have been unsuccessful.

    Thank you,

    Todd
     
    Todd A, Feb 26, 2004
    #1
    1. Advertising

  2. Todd A

    mikeb Guest

    Todd A wrote:
    > If I use the following in my code behind page:
    >
    > Public Class _Default
    > Inherits System.Web.UI.Page
    >
    > The page will compile with no errors from the command line compiler
    > (vbc.exe)
    >
    > But, If I insert my own base page to inherit from, say,
    >
    > Public Class _Default
    > Inherits BaseWebPage
    >
    > I am unable to get the code to compile, even if I compile BaseWebPage first
    > and make a reference to it.
    > Do I have to include the code for BaseWebPage with every page that wants to
    > inherit it?
    > I've tried a number of things here, but have been unsuccessful.
    >


    Are you sure that the name of your class is simply "BaseWebPage"?
    usually classes - even your custom coded ones - are somewhere in a
    namespace hierarchy.

    If you're not sure, run ildasm on the assembly that contains the
    BaseWebPage class - it'll show you the namespace (if there is one).

    Remember that if you're creating your class using VB.NET the namespace
    that it will reside in does not have to come from the source file - the
    compiler has a command line option "/rootnamespace" which can specify
    one. VS.NET VB projects default the rootnamespace to the name of the
    project.

    --
    mikeb
     
    mikeb, Feb 26, 2004
    #2
    1. Advertising

  3. Todd A

    Todd A Guest

    MIke,
    Good point.
    I am using a response file, and in the file, I specify my namespace with
    /rootnamespace:
    Here is a real sample:

    /target:Library
    /out:"C:\Inetpub\wwwroot\stpaulmoms\bin\_Default.dll"
    /rootnamespace:StPaulMoms
    /optimize+
    /reference:"System.dll","System.Data.dll","System.Drawing.dll","System.Web.d
    ll","System.Xml.dll","System.Design.dll","C:\Inetpub\wwwroot\stpaulmoms\bin\
    DAL.dll","C:\Inetpub\wwwroot\stpaulmoms\bin\StPaulMomsMB.dll"
    /Imports:Microsoft.VisualBasic,System,System.Collections,System.Configuratio
    n,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlCont
    rols,System.Web.UI.WebControls
    /res:"C:\Inetpub\wwwroot\stpaulmoms\StPaulMoms.Default.resources"
    "C:\Inetpub\wwwroot\stpaulmoms\Default.aspx.vb"

    My goal is to give each web page their own DLL. That's why I'm deviating
    from the VS.NET Model of building my assemblies.
    If my BaseWebPage class (It is named BaseWebPage), which all my web pages
    inherit from, is just a stand alone compiled DLL, how can I compile one
    class that inherits from a class inside an already compiled dll?

    Thanks,
    Todd

    "mikeb" <> wrote in message
    news:e50L6kK$...
    > Todd A wrote:
    > > If I use the following in my code behind page:
    > >
    > > Public Class _Default
    > > Inherits System.Web.UI.Page
    > >
    > > The page will compile with no errors from the command line compiler
    > > (vbc.exe)
    > >
    > > But, If I insert my own base page to inherit from, say,
    > >
    > > Public Class _Default
    > > Inherits BaseWebPage
    > >
    > > I am unable to get the code to compile, even if I compile BaseWebPage

    first
    > > and make a reference to it.
    > > Do I have to include the code for BaseWebPage with every page that wants

    to
    > > inherit it?
    > > I've tried a number of things here, but have been unsuccessful.
    > >

    >
    > Are you sure that the name of your class is simply "BaseWebPage"?
    > usually classes - even your custom coded ones - are somewhere in a
    > namespace hierarchy.
    >
    > If you're not sure, run ildasm on the assembly that contains the
    > BaseWebPage class - it'll show you the namespace (if there is one).
    >
    > Remember that if you're creating your class using VB.NET the namespace
    > that it will reside in does not have to come from the source file - the
    > compiler has a command line option "/rootnamespace" which can specify
    > one. VS.NET VB projects default the rootnamespace to the name of the
    > project.
    >
    > --
    > mikeb
     
    Todd A, Feb 26, 2004
    #3
  4. Todd A

    mikeb Guest

    Todd A wrote:
    > MIke,
    > Good point.
    > I am using a response file, and in the file, I specify my namespace with
    > /rootnamespace:
    > Here is a real sample:
    >
    > /target:Library
    > /out:"C:\Inetpub\wwwroot\stpaulmoms\bin\_Default.dll"
    > /rootnamespace:StPaulMoms
    > /optimize+
    > /reference:"System.dll","System.Data.dll","System.Drawing.dll","System.Web.d
    > ll","System.Xml.dll","System.Design.dll","C:\Inetpub\wwwroot\stpaulmoms\bin\
    > DAL.dll","C:\Inetpub\wwwroot\stpaulmoms\bin\StPaulMomsMB.dll"
    > /Imports:Microsoft.VisualBasic,System,System.Collections,System.Configuratio
    > n,System.Data,System.Drawing,System.Web,System.Web.UI,System.Web.UI.HtmlCont
    > rols,System.Web.UI.WebControls
    > /res:"C:\Inetpub\wwwroot\stpaulmoms\StPaulMoms.Default.resources"
    > "C:\Inetpub\wwwroot\stpaulmoms\Default.aspx.vb"


    I assume that this is the response file used to compile the codebehind page.

    I think what we need to look at is the response file and command line
    used to build whatever assembly the BaseWebPage class resides in. I
    assume it's either DAL.dll or StPaulMomsMB.dll since those are the only
    non-framework assemblies referenced above.

    >
    > My goal is to give each web page their own DLL. That's why I'm deviating
    > from the VS.NET Model of building my assemblies.
    > If my BaseWebPage class (It is named BaseWebPage), which all my web pages
    > inherit from, is just a stand alone compiled DLL, how can I compile one
    > class that inherits from a class inside an already compiled dll?
    >
    > Thanks,
    > Todd
    >
    > "mikeb" <> wrote in message
    > news:e50L6kK$...
    >
    >>Todd A wrote:
    >>
    >>>If I use the following in my code behind page:
    >>>
    >>>Public Class _Default
    >>> Inherits System.Web.UI.Page
    >>>
    >>>The page will compile with no errors from the command line compiler
    >>>(vbc.exe)
    >>>
    >>>But, If I insert my own base page to inherit from, say,
    >>>
    >>>Public Class _Default
    >>> Inherits BaseWebPage
    >>>
    >>>I am unable to get the code to compile, even if I compile BaseWebPage

    >
    > first
    >
    >>>and make a reference to it.
    >>>Do I have to include the code for BaseWebPage with every page that wants

    >
    > to
    >
    >>>inherit it?
    >>>I've tried a number of things here, but have been unsuccessful.
    >>>

    >>
    >>Are you sure that the name of your class is simply "BaseWebPage"?
    >>usually classes - even your custom coded ones - are somewhere in a
    >>namespace hierarchy.
    >>
    >>If you're not sure, run ildasm on the assembly that contains the
    >>BaseWebPage class - it'll show you the namespace (if there is one).
    >>
    >>Remember that if you're creating your class using VB.NET the namespace
    >>that it will reside in does not have to come from the source file - the
    >>compiler has a command line option "/rootnamespace" which can specify
    >>one. VS.NET VB projects default the rootnamespace to the name of the
    >>project.
    >>
    >>--
    >>mikeb

    >
    >
    >



    --
    mikeb
     
    mikeb, Feb 26, 2004
    #4
  5. Todd A

    Todd A Guest

    Thanks Mike,
    That did the trick.

    I've been away from technology for awhile, so this response is late.

    Here's one more question if you have time:

    What about vb files that are just MODULES and not classes?
    Example: abc.dll is an assembly that has nothing but a public module in it.
    xyz.dll fails on compilation when code in xyz is referencing code in abc.
    Even though I include the reference to abc.dll when I try to compile
    xyz.dll, it fails. Is there something special I should know about
    compileing modules and referencing them?

    Thanks

    Todd
     
    Todd A, Mar 2, 2004
    #5
  6. Todd A

    mikeb Guest

    Todd A wrote:

    > Thanks Mike,
    > That did the trick.
    >
    > I've been away from technology for awhile, so this response is late.
    >
    > Here's one more question if you have time:
    >
    > What about vb files that are just MODULES and not classes?
    > Example: abc.dll is an assembly that has nothing but a public module in it.
    > xyz.dll fails on compilation when code in xyz is referencing code in abc.
    > Even though I include the reference to abc.dll when I try to compile
    > xyz.dll, it fails. Is there something special I should know about
    > compileing modules and referencing them?
    >


    I'm not a VB.NET expert, but as far as I know, VB.NET Modules are simply
    a way to provide something like global variables and non-class-based
    functions.

    Members of a module are accessible within a namespace without specifying
    the name of the module - you would still have to import the namespace
    containing the module (or specify the namespace explicitly).

    So if you have a something like:

    namespace NS1
    public module ModuleX
    sub test( s as string)
    Console.WriteLine( "Inside NS1.ModuleX.test")
    end sub
    end module
    end namespace

    The test() subroutine can be called using any of the following:

    NS1.test( "x")
    NS1.ModuleX.test( "x")
    test("x") ' only if there's an "imports NS1" statement

    Remember that even when compiling assemblies that contain VB.NET
    Modules, the Module might be a member of a namespace by virtue of a
    compiler option - just like when compiling a class.

    Personally, I think that the namespace a type resides in should be
    specified in the source code and that it is a mistake for the VB.NET
    compiler to have that option. But it does, and your build environment
    needs to take it into account.

    --
    mikeb
     
    mikeb, Mar 2, 2004
    #6
  7. Todd A

    Todd A Guest

    Thanks again Mike,
    After tinkering a bit with what you suggested, I found that my module wasn't
    declared Public. If you don't stipulate either Public or Private, the
    module will default to Private. This was causing the problem.

    That was the last piece to my puzzle. Thanks again.

    -Todd

    "mikeb" <> wrote in message
    news:...
    > Todd A wrote:
    >
    > > Thanks Mike,
    > > That did the trick.
    > >
    > > I've been away from technology for awhile, so this response is late.
    > >
    > > Here's one more question if you have time:
    > >
    > > What about vb files that are just MODULES and not classes?
    > > Example: abc.dll is an assembly that has nothing but a public module in

    it.
    > > xyz.dll fails on compilation when code in xyz is referencing code in

    abc.
    > > Even though I include the reference to abc.dll when I try to compile
    > > xyz.dll, it fails. Is there something special I should know about
    > > compileing modules and referencing them?
    > >

    >
    > I'm not a VB.NET expert, but as far as I know, VB.NET Modules are simply
    > a way to provide something like global variables and non-class-based
    > functions.
    >
    > Members of a module are accessible within a namespace without specifying
    > the name of the module - you would still have to import the namespace
    > containing the module (or specify the namespace explicitly).
    >
    > So if you have a something like:
    >
    > namespace NS1
    > public module ModuleX
    > sub test( s as string)
    > Console.WriteLine( "Inside NS1.ModuleX.test")
    > end sub
    > end module
    > end namespace
    >
    > The test() subroutine can be called using any of the following:
    >
    > NS1.test( "x")
    > NS1.ModuleX.test( "x")
    > test("x") ' only if there's an "imports NS1" statement
    >
    > Remember that even when compiling assemblies that contain VB.NET
    > Modules, the Module might be a member of a namespace by virtue of a
    > compiler option - just like when compiling a class.
    >
    > Personally, I think that the namespace a type resides in should be
    > specified in the source code and that it is a mistake for the VB.NET
    > compiler to have that option. But it does, and your build environment
    > needs to take it into account.
    >
    > --
    > mikeb
     
    Todd A, Mar 3, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Cowald
    Replies:
    4
    Views:
    1,102
    Tohid
    Oct 23, 2003
  2. Todd Acheson

    RESX Files and command line compilation

    Todd Acheson, Nov 21, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    672
    Todd Acheson
    Nov 24, 2003
  3. Alex Nitulescu
    Replies:
    0
    Views:
    361
    Alex Nitulescu
    Feb 22, 2005
  4. ton
    Replies:
    1
    Views:
    1,035
    Teemu Keiski
    Jun 24, 2007
  5. haziz
    Replies:
    2
    Views:
    2,808
    Juha Nieminen
    Apr 10, 2012
Loading...

Share This Page