Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unable to register business object in WPF
Message
De
15/05/2009 14:31:49
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
15/05/2009 13:22:54
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Divers
Thread ID:
01398219
Message ID:
01400183
Vues:
58
Lynn,

Any reason why you can't register your business objects in the constructor before the InitalizeComponent call? Any bound controls won't be created until the InitializeComponent.

You should have a constructor automatically in your code behind.

Tim

>Thanks, Sid.
>I'm trying to register the business object in my window1.xaml.cs file: The code behind file for my main XAML window.
>I put the register call in the Window_Initialized event handler because the registration needs to happen before any datasources are bound, which has happened by the time the Window_Loaded event handler has fired. I tried putting a call to InitializeComponent() in the Window_Loaded handler. The registration happens well before that and ALWAYS fails in exactly the same way:
>"Object reference not set to an instance of an object." Here is the trace stack:
>System.NullReferenceException was unhandled by user code
> Message="Object reference not set to an instance of an object."
> Source="OakLeaf.MM2008.WPF"
> StackTrace:
> at OakLeaf.MM.Main.WPF.mmBusinessWindow.CreateUIHelper()
> at OakLeaf.MM.Main.WPF.mmBaseWindow.get_UIHelper()
> at OakLeaf.MM.Main.WPF.mmBusinessWindow.get_BusinessUIHelper()
> at OakLeaf.MM.Main.WPF.mmBusinessWindow.RegisterPrimaryBizObj(mmBusinessObject businessObject)
> at EWB_Prototype.Window1.mainWindow_Initialized(Object sender, EventArgs e) in E:\Projects\whiteboard\Sandbox\Lynn\version0.02\EWB_Prototype\Window1.xaml.cs:line 53
> at System.Windows.FrameworkElement.RaiseInitialized(EventPrivateKey key, EventArgs e)
> at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
> at System.Windows.FrameworkElement.TryFireInitialized()
> at System.Windows.FrameworkElement.EndInit()
> at System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
> InnerException:
>
>Here is part of my code:
>
>namespace EWB_Prototype
>{
>    /// <summary>
>    /// Interaction logic for Window1.xaml
>    /// </summary>
>    public partial class Window1 : mmBusinessWindow
>    {
>
>        private Patient pPatient;
>        public String savedLayout = "";
>        public String _targetItem = null;
>        private XamDataGrid sourceGrid;
>        public String rootpath;
>        public string fnSchedule = null;
>        public static ArrayList openTherapistCards = new ArrayList();
>        public static ArrayList openPatientCards = new ArrayList();
>        public static ArrayList openAideCards = new ArrayList();
>        public static string newStatus = "";
>        public static String path = Directory.GetCurrentDirectory();
>
>        private void mainWindow_Initialized(object sender, EventArgs e)
>        {
>            //Register business objects
>            this.pPatient = (Patient)this.RegisterPrimaryBizObj(new Patient());
>
>            //Get the schedule filename from the app.config file
>            fnSchedule = ConfigurationManager.AppSettings["Schedule"];
>        }
>
>        private void XamRibbonWindow_Loaded(object sender, RoutedEventArgs e)
>        {
>            // this.therapistPoolPane.IsPinned = false;
>            // this.aidePoolPane.IsPinned = false;
>
>            //Get the root path for the application
>            String path = Directory.GetCurrentDirectory();
>            int loc = path.IndexOf("\\bin");
>            rootpath = path.Substring(0, loc);
>
>Any ideas from anyone would be greatly appreciated.
>Thanks!
>Lynn 8-)
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform