473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Error (Object not set)

Hello,
I am doing this initialization :
this.oXmlDoc=new XmlDocument();

in InitializeComponent() function.
And once in a while because of some reason I can't detect this statement
is being erased and I get the Object not initialized error.
Why is this happens?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
2 1045
On Sun, 17 Apr 2005 05:53:22 -0700, juli jul wrote:
Hello,
I am doing this initialization :
this.oXmlDoc=new XmlDocument();

in InitializeComponent() function.
And once in a while because of some reason I can't detect this statement
is being erased and I get the Object not initialized error.
Why is this happens?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***


Do I understand you right: You manually add this.oXmlDoc=new XmlDocument();
to the InitializeComponent() method?

If so, maybe you should read the comment above InitializeComponent() which
says:

/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.

So as it says: "do not modify the contents of this method".

The reason is that: when you design your form the designer places generated
code into this method. As soon as you add stuff there by hand the designer
doesn't really know anything about it and changes are good that it gets
lost by the time just because the designer deletes it.

So instead of placing your line of code in the InitializeComponent() method
you should place it in the constructor. AFTER the call to
InitializeComponent(). e.g.:

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
this.oXmlDoc=new XmlDocument();
}

hth
--
Claudio Grazioli
http://www.grazioli.ch
Nov 17 '05 #2
Thank you! I will do it.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ike | last post by:
Anyone knows what cuases this under 6.0 ? -Ike
3
by: Kakaiya | last post by:
Error message: An unhandled exception of type 'System.InvalidCastException' occurred in test.dll Additional information: Specified cast is not valid. Public Class Form1 Inherits...
4
by: Steve Long | last post by:
Hello, I hope this is the right group to post this to. I'm trying to serialize a class I've written and I'd like to be able to serialze to both binary and xml formats. Binary serialization is...
17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
3
by: Richard Hollenbeck | last post by:
I've marked the line in this subroutine where I've been getting this error. It may be something stupid but I've been staring at this error trying to fix it for over an hour. I'm pretty sure the...
4
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any...
2
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' Application. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.