DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Jason Salas Guest

    Objetc reference not set to instance of an object

    This is the .NET error I hate the worst: "Object reference not set to an
    instance of an object."

    Anyone got any ideas why I would be properly instantiating a custom class I
    wrote, and I still get the above error?

    NewsStory item = new
    NewsStory(Request.Form["fname"].Trim(),Request.Form["lname"].Trim(),Request.
    Form["age"].Trim());

    The funny thing is, the default constructor I defined for the class uses the
    above signature, requiring those 3 parameters. So, I wrote a simpler
    constructor as a test:

    // the code
    public class NewsStory
    {
    public NewsStory()
    {}
    }

    ....and tried instantiating that one in code:

    NewsStory item = new NewsStory();

    ....and it worked perfectly.

    Got any fixes?





  2. #2
    Jason Salas Guest

    Re: Objetc reference not set to instance of an object

    never mind...i got it.


    "Jason Salas" <jason@kuam.com> wrote in message
    news:3f29b6e4@tnews.web.devx.com...
    > This is the .NET error I hate the worst: "Object reference not set to an
    > instance of an object."
    >
    > Anyone got any ideas why I would be properly instantiating a custom class

    I
    > wrote, and I still get the above error?
    >
    > NewsStory item = new
    >

    NewsStory(Request.Form["fname"].Trim(),Request.Form["lname"].Trim(),Request.
    > Form["age"].Trim());
    >
    > The funny thing is, the default constructor I defined for the class uses

    the
    > above signature, requiring those 3 parameters. So, I wrote a simpler
    > constructor as a test:
    >
    > // the code
    > public class NewsStory
    > {
    > public NewsStory()
    > {}
    > }
    >
    > ...and tried instantiating that one in code:
    >
    > NewsStory item = new NewsStory();
    >
    > ...and it worked perfectly.
    >
    > Got any fixes?
    >
    >
    >
    >




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links