Create a component

Discussion in 'ASP .Net Web Controls' started by ruca, Feb 10, 2004.

  1. ruca

    ruca Guest

    Hi people,

    I have a .vb file and I want to create a .dll file.

    I'm puting this line in command line:
    vbc /t:library
    /r:system.dll,system.web.dll,system.data.dll,microsoft.visualbasic.dll
    C:\marcacao.vb

    The compiler give me errors only because I have both Response and Request
    objects in my .vb file.
    What do I have to add more in command line?



    --
    Thanks (if you help me)
    Hope this helps (if I help you)

    ruca
     
    ruca, Feb 10, 2004
    #1
    1. Advertising

  2. ruca

    nfedin Guest

    Because you are compiling into a DLL, the DLL doesn't have access to
    the response and request objects by default. You have two options.

    1.) You could reference system.web.httpcontext.current in your DLL,
    which would be the simplest.

    2.) Create a class to manage the ASP objects for your DLL, for
    example

    Imports System
    Imports System.Web
    Imports System.web.httpcontext
    Imports System.Web.SessionState

    Public Class ASPObjects
    '*********************************************************
    'Use this class to reference ASP.Net objects inside a .NET dll
    'i.e. Application, Session, Response, Request, etc.
    '*********************************************************
    Public objHttpContext As HttpContext

    Public objHttpResponse As HttpResponse
    Public objHttpRequest As HttpRequest
    Public objHttpApplication As HttpApplicationState
    Public objhttpSession As HttpSessionState
    'Public strUserAgent As String

    Public Sub New()

    ' Get the HttpContext object for the current HTTP request.
    objHttpContext = HttpContext.Current()

    ' Get the Application State object.
    objHttpApplication = objHttpContext.Application

    ' Get the Session object.
    objhttpSession = objHttpContext.Session

    ' Get the Response object.
    objHttpResponse = objHttpContext.Response

    ' Get the Request object.
    objHttpRequest = objHttpContext.Request

    ' This code uses the Request object.
    ' You can use other intrinsic objects in a similar fashion
    'strUserAgent =
    objHttpRequest.ServerVariables("HTTP_USER_AGENT")

    ' This code uses the Response object.
    'objHttpResponse.Write("HTTP USER AGENT: ")
    'objHttpResponse.Write(strUserAgent)
    end sub
    End Class



    Do either of these and you'll be able to access the ASP objects,

    Neil


    "ruca" <> wrote in message news:<>...
    > Hi people,
    >
    > I have a .vb file and I want to create a .dll file.
    >
    > I'm puting this line in command line:
    > vbc /t:library
    > /r:system.dll,system.web.dll,system.data.dll,microsoft.visualbasic.dll
    > C:\marcacao.vb
    >
    > The compiler give me errors only because I have both Response and Request
    > objects in my .vb file.
    > What do I have to add more in command line?
     
    nfedin, Feb 10, 2004
    #2
    1. Advertising

  3. ruca

    ruca Guest

    It doesn't worked

    Any more solutions???


    --
    Thanks (if you help me)
    Hope this helps (if I help you)

    ruca

    "nfedin" <> escreveu na mensagem
    news:...
    > Because you are compiling into a DLL, the DLL doesn't have access to
    > the response and request objects by default. You have two options.
    >
    > 1.) You could reference system.web.httpcontext.current in your DLL,
    > which would be the simplest.
    >
    > 2.) Create a class to manage the ASP objects for your DLL, for
    > example
    >
    > Imports System
    > Imports System.Web
    > Imports System.web.httpcontext
    > Imports System.Web.SessionState
    >
    > Public Class ASPObjects
    > '*********************************************************
    > 'Use this class to reference ASP.Net objects inside a .NET dll
    > 'i.e. Application, Session, Response, Request, etc.
    > '*********************************************************
    > Public objHttpContext As HttpContext
    >
    > Public objHttpResponse As HttpResponse
    > Public objHttpRequest As HttpRequest
    > Public objHttpApplication As HttpApplicationState
    > Public objhttpSession As HttpSessionState
    > 'Public strUserAgent As String
    >
    > Public Sub New()
    >
    > ' Get the HttpContext object for the current HTTP request.
    > objHttpContext = HttpContext.Current()
    >
    > ' Get the Application State object.
    > objHttpApplication = objHttpContext.Application
    >
    > ' Get the Session object.
    > objhttpSession = objHttpContext.Session
    >
    > ' Get the Response object.
    > objHttpResponse = objHttpContext.Response
    >
    > ' Get the Request object.
    > objHttpRequest = objHttpContext.Request
    >
    > ' This code uses the Request object.
    > ' You can use other intrinsic objects in a similar fashion
    > 'strUserAgent =
    > objHttpRequest.ServerVariables("HTTP_USER_AGENT")
    >
    > ' This code uses the Response object.
    > 'objHttpResponse.Write("HTTP USER AGENT: ")
    > 'objHttpResponse.Write(strUserAgent)
    > end sub
    > End Class
    >
    >
    >
    > Do either of these and you'll be able to access the ASP objects,
    >
    > Neil
    >
    >
    > "ruca" <> wrote in message

    news:<>...
    > > Hi people,
    > >
    > > I have a .vb file and I want to create a .dll file.
    > >
    > > I'm puting this line in command line:
    > > vbc /t:library
    > > /r:system.dll,system.web.dll,system.data.dll,microsoft.visualbasic.dll
    > > C:\marcacao.vb
    > >
    > > The compiler give me errors only because I have both Response and

    Request
    > > objects in my .vb file.
    > > What do I have to add more in command line?
     
    ruca, Feb 10, 2004
    #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. Soni
    Replies:
    0
    Views:
    1,096
  2. Karuppasamy

    com+ component and Component Service

    Karuppasamy, Jan 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    627
    Karuppasamy
    Jan 13, 2004
  3. Karuppasamy

    com+ component and Component Service

    Karuppasamy, Jan 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,553
  4. Karuppasamy

    Remoting Component --> Com+ Component:

    Karuppasamy, Jan 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    675
    Karuppasamy
    Jan 15, 2004
  5. Jim Hammond
    Replies:
    1
    Views:
    758
    Jim Hammond
    Nov 12, 2003
Loading...

Share This Page