.NET Components for Mobility

switching from 3.2 eval to 4

Last post 03-30-2010 1:40 PM by grizli. 16 replies.
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts: Previous Next
  • 02-14-2010 6:24 AM

    switching from 3.2 eval to 4

     Hi all

    since version 3.2 eval appeared to provide most of what we needed, we decided to buy the commercial version.
    after replacing the references, simple things appear to melfunction: the first hurdle is that after instantiating a new outlookSession, and trying to run a foreach loop on the smsAccount Inbox, the SmsMessage returned is null... so i crash where the old version has been running smoothly.
    i couldn't find a checklist for version replacement, so if there's one floating about, or if anyone came across stuff like what happened to me, i'd appreciate a pointer

    thanks

    grizli

  • 02-14-2010 3:41 PM In reply to

    Re: switching from 3.2 eval to 4

    Can you post a code snippet to demonstrate the Sms issue you have described.

    Thanks,

    Peter

  • 02-15-2010 4:34 AM In reply to

    Re: switching from 3.2 eval to 4

     Hi Peter

    the following was called after  my form init : the goal is to find if a certain (registration) sms was recieved:

     

                    OLS = new OutlookSession();
                    foreach (SmsMessage sms in OLS.SmsAccount.Inbox)
                    {

                        //this if is my current workaround in bold. the code even finds the required message, but...

                        //had to add this after the version change

                        //otherwise i'd get an unhandled NullReferenceException on accessing the sms instance...

                       //i agree this is healthier anyway, but it just leads me to wonder what other

                       //things i'm missing.... 

                       if (sms == null)
                        {
                            continue;
                        }


                        if (sms.From.Address.CompareTo("**knownNumber**") == 0 || sms.From.Address.CompareTo("**+knownNumber**") == 0 || sms.From.Name.CompareTo("**anotherKnownNumber**") == 0)

                        {
                            string body = sms.Body.Trim();
                            string key = "predefined info ";

                            //....
                            //do some annoying string parsing

                            //...

                           CommitUserSettings();
                            break;
                        }
                    }  //end of foreach

     

     

    thanks a lot

    Aviv

  • 02-15-2010 8:00 AM In reply to

    Re: switching from 3.2 eval to 4

     Hi Peter

     

    some more info:

    I already posted here that on smsMessageCopied event, if the message was originally a reply , i get the event but getItemByItemID returns null.

    I didn't get a solution to that, but found that if i go through the sentItems folder and check for timestamp deltas i can find the message

    the Method is as follows:

    void OLS_MessagingItemCopied(object sender, MessagingItemEventArgs e)
            {
                try
                {
                    //if (e.ParentItemId.ToString().CompareTo(OLS.SmsAccount.SentItems.ItemId.ToString()) == 0)
                    if (e.ParentItemId== OLS.SmsAccount.SentItems.ItemId)
                    {

                        SmsMessage sm = (SmsMessage)OLS.GetItemByItemId(e.ItemId);//(AppState.Instance.MessageItemID);//(e.ItemId);//OLS.SmsAccount.SentItems[OLS.SmsAccount.SentItems.Count-1];//OLS.SmsAccount.Drafts[0];//sm;

                        if (sm == null)
                        {
                            if (Constants.Debug)
                                DebugOutput.Instance.WriteLine("OLS_MessagingItemCopied: message by item id is null, scanning through sent items");
                            TimeSpan ts = new TimeSpan(0, 0, 2);
                            DateTime nowTime = DateTime.Now;
                            for (int i = 0; i < OLS.SmsAccount.SentItems.Count; ++i)
                            {
                                SmsMessage sms = OLS.SmsAccount.SentItemsIdea;

                                //used to work OK. now i get sms == null... on debugging, iterating through all of them returns null

                               //had to add the bolded section so it wouldn't crash, and yet i can't see the new message 

                                if(sms == null)
                                {
                                    continue;
                                }

                                if (nowTime - (DateTime)sms.LastModified < ts && sms.Read == false)
                                { 

                                //...

                                }

                       }

                   }

               }

           }

  • 02-17-2010 8:20 PM In reply to

    Re: switching from 3.2 eval to 4

    Does this GetItemByItemId issue affect a specific target device type? or are you seeing it on multiple OS versions?

    Peter

  • 02-18-2010 11:47 AM In reply to

    Re: switching from 3.2 eval to 4

     Hi Peter

    I've tested on WM 6.1 only, but I've seen it on both HTC Tytn II, Diamond touch II and on Sony Ericsson Xperia X1 (my current test devices)

    thanks

    Aviv

  • 02-20-2010 6:05 PM In reply to

    Re: switching from 3.2 eval to 4

    How are you copying the messages since the Messaging application supports only Move operations?

    Peter

  • 02-21-2010 3:03 AM In reply to

    Re: switching from 3.2 eval to 4

     i'm using a native c++  adviseSink to delete the sms before it's sent and copy it to the target for processing in managed code...

    i found no way to use only the managed code, since the event surface too late, and the message was always sent.

     

    Aviv

  • 02-28-2010 3:41 AM In reply to

    Re: switching from 3.2 eval to 4

    In order to test the behaviour on message copy I added a CopyTo method to the Message type which will show up in future versions. I tested on WM6.5 and couldn't duplicate the problem. However on earlier versions the GetItemByItemId would fail and internally the method through an exception indicating the item could not be found. On looking at the Messaging application the copied item was there so I iterated through the target folder and the returned ItemIds are different. I'm going to have to continue this investigation and may need some help from Microsoft to explain what is happening.

    Peter

  • 03-14-2010 4:57 AM In reply to

    Re: switching from 3.2 eval to 4

     Hi Peter

    I've switched to creating a new message and copying all the contents from the old one before deleting it, so I don't use message copy anymore. Still I get nulls on getItemById and on iterating through folders. i really need something here, we bought the full version for deployment, and now we're stuck again...

     

    thanks

    Aviv

  • 03-14-2010 5:33 AM In reply to

    Re: switching from 3.2 eval to 4

    Are you sure that the issue here is GetItemById failing or is the ItemId invalid? Is there any chance that some of the items in the folder are not SMS messages? for example MMS or configuration related messages?

    Peter

  • 03-14-2010 5:48 AM In reply to

    Re: switching from 3.2 eval to 4

     I'm iterating through the SentItems folder. All of them return null... anyway, if i'm doing a foreach(...) loop, how come i get into the loop with a null?

    next thing i'm gonna test is a hard reset, see if there's a version conflict or something, but I'm not sure what's going on here

     

    Aviv 

  • 03-14-2010 8:36 PM In reply to

    Re: switching from 3.2 eval to 4

    I don't see how this is possible. If there is no item returned then MoveNext will return false and so the enumeration loop will stop. It is perhaps possible that the null reference exception is thrown when accessing a property of the SmsMessage. For example messages in the SentItems folder will return null for the From recipient as these details are not written to the message item. If this is not the issue then I would suspect something is corrupt with the debug information for your application. Try doing a full clean and rebuild of your solution and try deleting all the application dlls etc on your target device and deploying again. If this doesn't work you could also try hard resetting the device. Check also if you have the latest service pack if you are using .NET 2.0.

    Peter

  • 03-15-2010 6:47 AM In reply to

    Re: switching from 3.2 eval to 4

     I don't really know how this foreach mess is possible (i know it shouldn't enter if the sms is null, but on adding "if(sms == null)continue;" it doesn't crash - meaning the nullReferenceException is from that....

    tried rebuilding to no avail. another thing i'm trying to investigate is whether the messages only look like correct sms's and are really created with errors. will try hard resetting and will post back on it all. thanks for the pointers

     

    Aviv

  • 03-18-2010 7:06 AM In reply to

    Re: switching from 3.2 eval to 4

    Hi Aviv,
    Could you try with for loops instead of foreach? I have experienced less problems with this approach and a great performance improvement because of the reduction of virtual calls. See http://blogs.msdn.com/netcfteam/archive/2005/05/04/414820.aspx
    Hope this helps.
Page 1 of 2 (17 items) 1 2 Next >
Copyright © 2001-2012 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting