Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

i am using Exchange server 2003, I am making SEARCH Request to fetch calender details( which is XML request string) using webdav HttpWebRequest for Resource Mailbox account in my asp.net Application.

i am getting "Object reference not set to an instance of an object" Exception.

can any one help me to find out causes of Object reference not set to an instance of an object and possible solution to troubleshoot this condition.

is there something i need to change at Exchange server 2003 resource mailbox setting to omit "Object reference not set to an instance of an object" Exception.

code: (it's only shows basic functionality)
C#
 HttpWebRequest oHTTPReq = (WebRequest.Create(url) as HttpWebRequest);
 oHTTPReq.Method = methodName;    
 oHTTPReq.ContentType = contentType;   //xml
//xmlRequest contains SEARCH Query String
 Byte[] byteXML = System.Text.Encoding.UTF8.GetBytes(xmlRequest);  
  
 oHTTPReq.ContentLength = byteXML.Length;

 Stream oStream = oHTTPReq.GetRequestStream();
 oStream.Write(byteXML, 0, byteXML.Length);
 oStream.Close();

 oHTTPRes = oHTTPReq.GetResponse();

 StreamReader oReader; 
 oReader = new StreamReader(oHTTPRes.GetResponseStream(), System.Text.Encoding.UTF8);          
 res = oReader.ReadToEnd();
 oHTTPRes.Close(); 


thanks
Posted
Updated 3-Feb-12 23:56pm
v5
Comments
CRDave1988 4-Feb-12 1:39am    
I think ur Problem is not of Exchange server 2003.
This Proble is of ur server side script (like .cs file).

but ur question is not clear so we cant help

improve ur question

-where u get this error
-some code where u get this error
-which language and platform u use for this

if u provide proper and enough information than someone may help u
parth891 4-Feb-12 9:35am    
Actually i am sending request for search operation(using XML string) to read calender details using HttpWebRequest on my Exchange Server 2003 for Resource Mailbox Account

i am getting exception on "GetResponse()"

i am using asp.net application

1 solution

"can any one help me to find out causes of Object reference not set to an instance of an object"

This is an odd question. The error means that the object was null, which means that your attempt to create it, failed. If you do not know that, then you should be reading a basic programming book and not trying to do what you're doing here. Also when you post code like this, tell us what line creates the error and what object is null, if you want more detailed help.
 
Share this answer
 
Comments
parth891 4-Feb-12 9:32am    
thanks @Christian for your advice to read basic programming book, it would be a great help.

as per my situation i cannot debug code so its weird for me to guess which line creates error.

if you have any idea like if resource mailbox account has something missing in configuration
or for exchange server 2003 i need some settings to be done.

should i need to put some extra condition to check for "empty or null" response in above code to stop causes exception. if can you pinch some lines that might causes this exception. for example .GetResponse() or .GetResponseStream() it would be great help.


thank for your reply.
Christian Graus 4-Feb-12 10:09am    
If you can't debug code, you can't program. Just set a breakpoint. Or, when the code blows up, look at what line is highlighted. Or add some message boxes in order to track which line blows up. There's lots of ways, and if you don't know them, you REALLY need to learn some basics in order to be able to write code. Yes, if you check if the object is null first, you can avoid the exception, but you can't make the code work without making it not null. Checking if an object is null before using it is another good programming practice that you should understand.

I suspect that oHTTPReq is null, so the first line is failing, but again, if you can't work that out, then you have close to no idea how to use the tools in question and you need to learn.

http://msdn.microsoft.com/en-us/library/sc65sadd.aspx is a good place to start.
parth891 9-Feb-12 2:27am    
hi christian i think for this question i got some config change of Virtual directory properties.....

do you have any idea about this question

http://www.codeproject.com/Questions/325365/500-Internal-Server-Error-for-WebDAV-Status-on-SEA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900