TReKiE / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
0 stars 0 forks source link

NullPointer Exception when Trying to get ContactCard [URGENT] #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Just trying to get ContactCards for my Contacts.
I am unable to catch this Exception, please help!
Thanks!
-john
----------------------------------------------------------
GetContactCard for ahirunopekle@hotmail.com
ContactCardCompletedHandler, blue_oceania@hotmail.com
GetContactCard for sidikpra@hotmail.com
System.Transactions Critical: 0 : <TraceRecord
xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System
/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Descr
iption>Unhandled
exception</Description><AppDomain>Com.HP.ESB.Socktop.UI.ClientApp.vshost.exe</Ap
pDomain><Exception><ExceptionType>System.NullReferenceException,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Object reference
not set to an instance of an object.</Message><StackTrace>   at
MSNPSharp.ContactSpaceService.&amp;lt;&amp;gt;c__DisplayClass2.&amp;lt;GetContac
tCard&amp;gt;b__0(Object
sender, GetXmlFeedCompletedEventArgs e)
   at
MSNPSharp.MSNWS.MSNSpaceService.SpaceService.OnGetXmlFeedOperationCompleted(Obje
ct
arg)
   at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object
state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(
TryCode
code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
   at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPool
WaitCallback
tpWaitCallBack)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object
state)</StackTrace><ExceptionString>System.NullReferenceException: Object
reference not set to an instance of an object.
   at
MSNPSharp.ContactSpaceService.&amp;lt;&amp;gt;c__DisplayClass2.&amp;lt;GetContac
tCard&amp;gt;b__0(Object
sender, GetXmlFeedCompletedEventArgs e)
   at
MSNPSharp.MSNWS.MSNSpaceService.SpaceService.OnGetXmlFeedOperationCompleted(Obje
ct
arg)
   at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object
state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(
TryCode
code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
   at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPool
WaitCallback
tpWaitCallBack)
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object
state)</ExceptionString></Exception></TraceRecord>

Original issue reported on code.google.com by johnpaul...@gmail.com on 20 Mar 2009 at 7:09

GoogleCodeExporter commented 9 years ago
When ContactCardCompleted occurs, did you check e.Error ?

If e.Error is not null, ContactCard is null. Some users haven't contact card.

Original comment by hepha...@gmail.com on 20 Mar 2009 at 7:25

GoogleCodeExporter commented 9 years ago
ContactCardCompletedHandler never gets called.
The exception is thrown inside the MSNPSharp, and i cannot catch it and move-on.

So basically i call "contact.GetContactCard(contact.Mail)" and MSNPSharp blows 
up.
and I tried to put try/catch arounf GetContactCard, and no luck.

Here is my code ContactCardCompletedHandler code:
----------------------
        private void ContactCardCompletedHandler(object sender,
ContactCardCompletedEventArgs e)
        {
            try
            {
                String email = "";
                if (e.ContactCard != null)
                {
                    email = e.ContactCard.Mail;
                }
                TraceMessage("ContactCardCompletedHandler, " + email);
                if (email.Length != 0)
                {
                    ...
                }
            }
            catch (Exception ex)
            {
                TraceException("ContactCardCompletedHandler", ex);
            }
        }

Original comment by johnpaul...@gmail.com on 20 Mar 2009 at 8:20

GoogleCodeExporter commented 9 years ago
Here is the code and stack-trace (attached as files)

i think its a particular contact that is a corner-case here.

cause i am avoid those null contact occurences...

i just want to be able to catch this corner case and move on..

thanks

Original comment by johnpaul...@gmail.com on 20 Mar 2009 at 8:28

Attachments:

GoogleCodeExporter commented 9 years ago
I found the issue:

This:

e.Result.GetXmlFeedResult.contactCard.elements.element 

is null

here is the offending code is MSNPSharp:

foreach (elementType element in 
e.Result.GetXmlFeedResult.contactCard.elements.element)
{
...
}

Original comment by johnpaul...@gmail.com on 20 Mar 2009 at 10:16

GoogleCodeExporter commented 9 years ago
ok, I've committed a fix in trunk, try it. If it works, I will close this issue.

Original comment by freezing...@gmail.com on 21 Mar 2009 at 5:15

GoogleCodeExporter commented 9 years ago

Original comment by freezing...@gmail.com on 22 Mar 2009 at 7:15

GoogleCodeExporter commented 9 years ago

Original comment by hepha...@gmail.com on 24 Mar 2009 at 2:13