Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 6th, 2010, 02:36 PM
Registered User
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Object reference not set to an instance of an object.

When I'm writing a unit test for failed authentication, I'm getting an error like this: Object reference not set to an instance of an object.

Here's my code(pretty simple):

//validate with wrong username
//The validation fails here(as expected) but I get the error: Object reference not set to an instance of an object.

ValidateUserResults validateUserTestFail = serviceClient.ValidateUser("wrongusername", "newPass1-i");
Assert.IsFalse(validateUserTestFail.Success, "Validate result should have been false");

// Authentication failed-wrong password
//The validation fails here too(as expected) but I don't get the error.

ValidateUserResults validateUserTestFail1 = serviceClient.ValidateUser("newuser1", "wrongpassword");
Assert.IsFalse(validateUserTestFail1.Success, "Validate result should have been true");

Can anybody please tell me why this is happening? I tried everything I can, but couldn't find a solution....

Thanks a lot in advance
  #2 (permalink)  
Old April 6th, 2010, 04:46 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

What is 'serviceClient'?

Obviously there is some code in the ValidateUser method that generates the error, so if you wrote that method go look in there.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
  #3 (permalink)  
Old April 6th, 2011, 06:11 AM
Registered User
 
Join Date: Sep 2004
Location: Madurai, Tamil Nadu, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What is the serviceClient? Whether you are creating an object or you are trying to access a Static Class? Anywhere you are trying to access any methods without initializing and instantiating a class inside your ValidateUser method? The exception may occur in the second method also but it don't reflect as the runtime stops the execution when it finds the exception.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
object reference not set to an instance of an object fraperz ASP.NET 3.5 Professionals 5 December 14th, 2009 03:45 AM
Object reference not set to an instance of an object. phuc2583 ASP.NET 3.5 Professionals 5 August 14th, 2009 10:56 AM
Chap 13 pg448: Object reference not set to an instance of an object tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 15 August 8th, 2009 06:14 AM
Object Reference not set to an instance of object srinivas_chakka ASP.NET 1.0 and 1.1 Professional 0 February 8th, 2006 11:56 AM



All times are GMT -4. The time now is 01:48 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.