Link to home
Start Free TrialLog in
Avatar of bizcrown101
bizcrown101

asked on

Object reference not set to an instance of an object - from DataSet

I am using visual web developer express and I am suddenly getting this error message when I try to build my site:

Error      1      Failed to generate code. Object reference not set to an instance of an object.      C:\Documents and Settings\cut\My Documents\Visual Studio 2005\WebSites\WebSite38\App_Code\MyDataSet.xsd      1      

My dataset was working fine until I opened up Visual Web Developer Express this morning and created a new query on my table adapter using the add query wizard.

Does anyone have any idea what might be going on?
Avatar of ethoths
ethoths

This is usually cause by either not calling New on an object or an null reference being trurned from a method that you expect to return an object. Since this is inside the auto-generated code of xsd yiou don't have too much control over the code in there. My guess is that either you cannot access the database or something in the database has changed. My advise would be to delete the xsd and regenerate it.

Avatar of bizcrown101

ASKER

Any idea as to what I might look for in the xsd file?

Aside from the one error message, I also get an INSANE amount of warnings about properties in my dataset being empty or null. It's almost as if there should be an instance of my dataset class instantiated somewhere, but it is missing. Is there somewhere in my project where an instance of this class should be created?
I would not try to debug the dataset. Any cahanges you make in the auto-generated code will be lost if you need to re-generate the code. Like I said, just delete it and re-create it. If you made it by dragging a stored procedure from the server explorer it'll only take a few minutes.

Rather than deleting the dataset and rebuilding it from scratch (I’m not using stored procedures), I opted to right-click on all the methods on all my table adapters and select "configure". I think this forced all the xml code to be re-built without me having to re-type in all my queries.

This seems to have fixed whatever problem was with my auto-generated dataset code.

Thank you for your suggestions ethoths.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial