Results 1 to 2 of 2

Thread: Object reference not set to an instance of an object...HELP

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2004
    Posts
    48

    Object reference not set to an instance of an object...HELP

    I found this great component on component 1 that does paypal for VB.net. The problem lies when I try to make it work in the code. This is what I have.

    VB Code:
    1. Protected WithEvents C1AddToCart1 As C1.Web.C1PayPal.C1AddToCart
    2.  
    3. Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    4. C1AddToCart1.CurrencyCode = C1.Web.C1PayPal.CurrencyEnum.USDollars
    5.         C1AddToCart1.Business = "******@hotmail.com"
    6.         C1AddToCart1.ItemName = "Test Item"
    7.         C1AddToCart1.ItemNumber = "0010001"
    8.         C1AddToCart1.ItemPrice = 15.95
    9. end Sub

    But when I press the button I get an Object Reference not set to an instance of an object:

    This is the stack trace
    [NullReferenceException: Object reference not set to an instance of an object.]
    WebApplication1.basic_customize.btnSubmit_Click(Object sender, EventArgs e) in C:\Documents and Settings\Cran56\VSWebCache\dirteelinens.com\basic_customize.ascx.vb:119
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain() +1277

    I have no clue why it's having a problem.

    Thanks,
    Cran56

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Even though you're Dim-ing your C1AddToCart1 as an object type, you never initialize it. Try something like .. As New C1.Web.C1PayPal.C1AddToCart, or maybe call a method that return an instance of that object, if available.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width