views:

125

answers:

2

When I try to publish my website (publishing has been working perfectly well for ages), I am getting an error. The output window is no help; the last line of the Pre-compiling stage is:

Building directory '/myPath/'.: Publication (web): Object reference is not set to an instance of an object.

There is no code showing to debug.

How can I debug this and find out what is causing this error? The website runs just fine in debug mode locally.

In response to John Saunders' comment below: Version is VS2008 9.0.30729 (appears to be the latest version; I've checked for updates) and .Net 3.5 SP1.

I've tried publishing to both a remote website server and a local (my computer) server. Publishing a dummy website with only a 'default.aspx' file works fine.

+1  A: 

When Visual Studio publishes a website it checks for errors in the code first. If it finds an error it won't publish. So it might be that you have an error somewhere in your C# code. That error:Object reference is not set to an instance of an object, will only be thrown when an attempt is made to reference that object. I suggest that you check your aspx.cs files.

Paul Rogers
+1 for answering my old question! do you have any suggestion about how I would debug this when the program compiles OK?
dsteele
A: 

Well I think you might have to go through the code and trigger the events that create new objects. Does your website have forms? Are you passing data between pages? What kind of events are triggered when a button is clicked? These are typically the kind of things that will create a new object in a webpage. I know it could be very annoying to go through all the pages but sometimes it happens.

Paul Rogers