.NET Framework Bookmark and Share   
 index > .NET StockTrader Sample Application > Object reference not set to an instance of an object.
 

Object reference not set to an instance of an object.


Hi, now when I try to loginto .NET StockTrader Web Application, I get the following error (with login uid:0, password xxx):

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 48:             BSLClient businessServicesClient = new BSLClient();
Line 49:             AccountDataUI customer = businessServicesClient.getAccountData(userid);
Line 50:             totalHoldings = businessServicesClient.getHoldings(userid);
Line 51:             Name.Text = customer.profileID + "!";
Line 52:             AccountID.Text = customer.accountID.ToString();

Source File: c:\stocktrader\StockTrader\StockTraderWebApplication\Trade\TradeHome.aspx.cs Line: 50

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   Trade.StockTraderWebApplicationServiceClient.BSLClient.getHoldings(String userID) in C:\stockrtm\StockTrader\StockTraderWebApplication\StockTraderWebApplicationClients\BSLClient.cs:259
   Trade.Web.TradeHome.Page_Load(Object sender, EventArgs e) in c:\stocktrader\StockTrader\StockTraderWebApplication\Trade\TradeHome.aspx.cs:50
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStage
ababacar
This might be becuase of changing the quote symbol name (from your previous post). The loader program and initial load from the installer not only load quote symbols, but also load a default number of holdings for each user; and the holding table contains the quote symbol---so if that symbol is no longer present, will be unable to locate it in the table to calculate current holding value, etc. No exceptions like these are trapped, by design, such that 500 errors are thrown back to the http client such that benchmarking software will show any such issues as errors.

If you want to change the way the quote data is loaded, here is a better strategy:

1) Use SQL Server Management studio to open a query windows against stocktraderdb.
2) Perform the following commands:

-DELETE FROM QUOTES
-DELETE FROM ORDERS
-DELETE FROM HOLDINGS

3) Load your new quote symbols
4) Now place orders against these new symbols as desired; all should be well, although no existing users will have any orders or holdings.

-Greg
Greg Leake, Microsoft
Gregory Leake

You can use google to search for other answers

Custom Search

More Threads

• .NET StockTrader SmartClient
• Object reference - accessing service from a Web Client
• Unable to cast transparent proxy to type 'ServiceContracts.IClientService'
• Server Error in '/ConfigWeb' Application
• Change the quotes
• Config Setup in DB
• .Net benchmark application without DB
• Send SMS from C# application
• Silent install or other scripted install options?
• Just not able to debug stock trader application from client to service.