Converting VS 2005 Web Site Project to VS 2005 Web Application Project

Discussion in 'ASP .Net' started by ITistic, Aug 20, 2007.

  1. ITistic

    ITistic Guest

    I've recently attempted converting a small VS 2005 ASP.NET Web Site
    Project to a Web Application Project using Scott's blog post:

    http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx

    This seems to be the best documentation available currently. After
    following all of the steps I've run into 1 problem. In the original
    Web Site project there were a few classes which were part of their own
    namespaces. Here's an example of one of these classes:

    Namespace DAL
    Public Class Delinquents
    Public Shared Function GetByID(ByVal ID As Integer) As
    BOL.Delinquent
    Dim db As Database = DatabaseFactory.CreateDatabase("dbNoPropane"),
    _
    SelectCmd As DbCommand =
    db.GetStoredProcCommand("usp_SelectDelinquentByID"), _
    dr As IDataReader, _
    MyD As New BOL.Delinquent

    db.AddInParameter(SelectCmd, "delinquent_id", DbType.Int32, ID)

    dr = db.ExecuteReader(SelectCmd)

    If dr.Read Then PopulateDelinquent(dr, MyD)

    SelectCmd.Dispose()

    Return MyD
    End Function
    End Class
    End Namespce

    In my code we'd call these methods as follows:

    MyD = DAL.Delinquents.GetByID(Value)

    All of this works fine in the Web Site project. After converting to
    the Web Application project per Scott's instructions none of these
    namespaces seem to be recognized by my code. The files are all still
    there, namespaces defined in them properly, etc. If I create a new
    class and put it in one of these namespaces my code recognizes IT
    fine, but it won't recognize the existing classes even though they are
    semantically the same. Anyone have any idea why this is and how I can
    fix this?

    Your response and time is greatly appreciated.

    Thanks!
    ITistic, Aug 20, 2007
    #1
    1. Advertising

  2. RE: Converting VS 2005 Web Site Project to VS 2005 Web Application Pro

    Typically what you would do here is take your DAL "Stuff" and compile it into
    a separate class library project, and have a reference to this project in
    your WAP application, along with the apppropriate using .. or Imports. ..
    statement. That's the whole idea of OOP and code - reusability.
    -- Peter
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "ITistic" wrote:

    > I've recently attempted converting a small VS 2005 ASP.NET Web Site
    > Project to a Web Application Project using Scott's blog post:
    >
    > http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx
    >
    > This seems to be the best documentation available currently. After
    > following all of the steps I've run into 1 problem. In the original
    > Web Site project there were a few classes which were part of their own
    > namespaces. Here's an example of one of these classes:
    >
    > Namespace DAL
    > Public Class Delinquents
    > Public Shared Function GetByID(ByVal ID As Integer) As
    > BOL.Delinquent
    > Dim db As Database = DatabaseFactory.CreateDatabase("dbNoPropane"),
    > _
    > SelectCmd As DbCommand =
    > db.GetStoredProcCommand("usp_SelectDelinquentByID"), _
    > dr As IDataReader, _
    > MyD As New BOL.Delinquent
    >
    > db.AddInParameter(SelectCmd, "delinquent_id", DbType.Int32, ID)
    >
    > dr = db.ExecuteReader(SelectCmd)
    >
    > If dr.Read Then PopulateDelinquent(dr, MyD)
    >
    > SelectCmd.Dispose()
    >
    > Return MyD
    > End Function
    > End Class
    > End Namespce
    >
    > In my code we'd call these methods as follows:
    >
    > MyD = DAL.Delinquents.GetByID(Value)
    >
    > All of this works fine in the Web Site project. After converting to
    > the Web Application project per Scott's instructions none of these
    > namespaces seem to be recognized by my code. The files are all still
    > there, namespaces defined in them properly, etc. If I create a new
    > class and put it in one of these namespaces my code recognizes IT
    > fine, but it won't recognize the existing classes even though they are
    > semantically the same. Anyone have any idea why this is and how I can
    > fix this?
    >
    > Your response and time is greatly appreciated.
    >
    > Thanks!
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Aug 20, 2007
    #2
    1. Advertising

  3. ITistic

    ITistic Guest

    Re: Converting VS 2005 Web Site Project to VS 2005 Web Application Pro

    On Aug 20, 3:58 pm, Peter Bromberg [C# MVP]
    <> wrote:
    > Typically what you would do here is take your DAL "Stuff" and compile it into
    > a separate class library project, and have a reference to this project in
    > your WAP application, along with the apppropriate using .. or Imports. ..
    > statement. That's the whole idea of OOP and code - reusability.
    > -- Peter
    > Recursion: see Recursion
    > site: http://www.eggheadcafe.com
    > unBlog: http://petesbloggerama.blogspot.com
    > BlogMetaFinder: http://www.blogmetafinder.com
    >
    > "ITistic" wrote:
    > > I've recently attempted converting a small VS 2005 ASP.NET Web Site
    > > Project to a Web Application Project using Scott's blog post:

    >
    > >http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx

    >
    > > This seems to be the best documentation available currently. After
    > > following all of the steps I've run into 1 problem. In the original
    > > Web Site project there were a few classes which were part of their own
    > > namespaces. Here's an example of one of these classes:

    >
    > > Namespace DAL
    > > Public Class Delinquents
    > > Public Shared Function GetByID(ByVal ID As Integer) As
    > > BOL.Delinquent
    > > Dim db As Database = DatabaseFactory.CreateDatabase("dbNoPropane"),
    > > _
    > > SelectCmd As DbCommand =
    > > db.GetStoredProcCommand("usp_SelectDelinquentByID"), _
    > > dr As IDataReader, _
    > > MyD As New BOL.Delinquent

    >
    > > db.AddInParameter(SelectCmd, "delinquent_id", DbType.Int32, ID)

    >
    > > dr = db.ExecuteReader(SelectCmd)

    >
    > > If dr.Read Then PopulateDelinquent(dr, MyD)

    >
    > > SelectCmd.Dispose()

    >
    > > Return MyD
    > > End Function
    > > End Class
    > > End Namespce

    >
    > > In my code we'd call these methods as follows:

    >
    > > MyD = DAL.Delinquents.GetByID(Value)

    >
    > > All of this works fine in the Web Site project. After converting to
    > > the Web Application project per Scott's instructions none of these
    > > namespaces seem to be recognized by my code. The files are all still
    > > there, namespaces defined in them properly, etc. If I create a new
    > > class and put it in one of these namespaces my code recognizes IT
    > > fine, but it won't recognize the existing classes even though they are
    > > semantically the same. Anyone have any idea why this is and how I can
    > > fix this?

    >
    > > Your response and time is greatly appreciated.

    >
    > > Thanks!


    I actually was planning on moving forward exactly as you described.
    Seeing this would not work after conversion I then created a separate
    Class Library project entitled "DAL" and copied these classes into
    that project. I then removed the "Namespace" statements from each
    class, and added the DAL project as a reference in my WAP. My thought
    was that I'd then be able to access the classes just as before by
    using "DAL.MethodName", but this TOO does not work. If I create a
    brand new class in the DAL library I can access it just fine. These
    classes that I am copying over exhibit the same problems as they did
    as part of the WAP. This must be some sort of bug.
    ITistic, Aug 21, 2007
    #3
    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. Ethan V
    Replies:
    2
    Views:
    4,988
    Ethan V
    Jun 25, 2006
  2. =?Utf-8?B?anJldHQ=?=
    Replies:
    1
    Views:
    912
    Laurent Bugnion
    Sep 26, 2006
  3. John Dalberg
    Replies:
    1
    Views:
    509
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Mar 28, 2007
  4. Lloyd Sheen
    Replies:
    1
    Views:
    331
    Lloyd Sheen
    Nov 15, 2007
  5. Replies:
    0
    Views:
    491
Loading...

Share This Page