0

Almost everything works great except one form that doesn't save some data to Azure database and I can't catch any info about exception i.e exception instance is null when break point stop in exception of type MobileServiceLocalStoreException. I checked the initialization of the local store and there is no problem with it, so what could be the reason behind this exception.

public async Task<T> CreateItemAsync(T item)
{
    try
    { 
        await table.InsertAsync(item);
    }
    catch(MobileServiceLocalStoreException ex)
    { // here exception occurd
        Debug.WriteLine(ex.Message);
    }
    catch(Exception ex)
    {

    }
    return item;
}
Paul Kertscher
  • 9,416
  • 5
  • 32
  • 57
xamo
  • 69
  • 10
  • How does your code look? Without a proper exception and the code it's really hard to tell what went wrong. Could you add a `Debug.WriteLine(e)` in the exception handler? – Paul Kertscher Mar 28 '18 at 08:44
  • As you see @PaulKertscher here ,the ex instance of local store exception is null. – xamo Mar 28 '18 at 09:05
  • I followed adrianHall online book to work with azure. – xamo Mar 28 '18 at 09:07
  • I can't see, but - yeah - if you are saying it. Are you running your app in Debug or release mode? Does the current code throw a `NullReferenceException` or does `Debug.WriteLine` write out anything? – Paul Kertscher Mar 28 '18 at 09:07
  • Is the build up to date? – Paul Kertscher Mar 28 '18 at 09:07
  • I'm running my app in debug mode, it doesn't throw any thing,firstly it was crash and close app, now it stops in that catch code but without any information about error. – xamo Mar 28 '18 at 09:09
  • Yes, and it save different data from other forms except this one which its code is very similar to other forms code. – xamo Mar 28 '18 at 09:11
  • Where did you put your breakpoint? If you are putting it before the body of the catch clause `ex` will be null in any case. Does it write something to the debug output? Do you know where to find the debug output? – Paul Kertscher Mar 28 '18 at 09:12
  • I put the breakpoint inside catch body, and I don't see any debug output in output window – xamo Mar 28 '18 at 09:14
  • And `ex` is still `null`? This is really weird. Have you checked if your build is up to date? Do you conincidentially have any field variable that is named `ex`? I don't know how `ex` should be `null`, tbh. – Paul Kertscher Mar 28 '18 at 09:15
  • It must be occur in other forms when I try to insert new items if the build is not up to date. There is no any field with name in the item of type T ex – xamo Mar 28 '18 at 09:19
  • Could you try to rename of of the `ex`es to something else? There was a bug that caused the very behavior you are describing (see [here](https://stackoverflow.com/questions/5634417/caught-exception-is-null-itself) - anyway, I don't know if this bug still exists) – Paul Kertscher Mar 28 '18 at 09:20
  • Thanks @PaulKertscher the exception message appeared and it saying "An insert operation on the item is already in the queue." – xamo Mar 28 '18 at 09:37

0 Answers0