Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unable to register business object in WPF
Message
From
06/05/2009 16:25:28
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Unable to register business object in WPF
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01398219
Message ID:
01398219
Views:
202
So far I haven't been able to successfully register a business object; it keeps telling me that the object instance is null. When I mouse over the object (see code snippet below), debug mode in VS2008, I see that this.Patient contains the structure of the Patient class, but no data. When I set up the DB connection, I tested it, so I know that the connection is valid.
Anyone have any ideas as to what I am doing wrong? I do not see anything in the examples that mention coding the HookConstructor() which is called when the business object is instantiated. Did I miss something? Are there any instructions out there that use WPF instead of WinForms?

The mm.net developer's guide is using a windows form app as an example to show how to register an object. They tell you to place the registraton code in the constructor so that the registration can occur before any data binding happens. However, the window1.xaml.cs file does not contain a constructor for Window1. And if you add one, it complains. There are two events that the XAML trigger when building the app: Initialize and Loaded. After doing some looking around, I ran finally came across the definitions for these two events: (http://msdn.microsoft.com/en-us/library/ms754221.aspx). Based on these definitions it appears that the Initialize event handler is where the registration needs to occur. Is this correct?

private Patient Patient = new Patient();
private void mainWindow_Initialized(object sender, EventArgs e)
{
//Register business objects
this.Patient = (Patient)this.RegisterPrimaryBizObj(new Patient());
}

Thanks!
Lynn 8-)
Lynn Sim
Perot Systems Corp
Next
Reply
Map
View

Click here to load this message in the networking platform