UserService fails with an exception

0 votes
Hi there, I am trying to implement a Userservice in which I am looking to authenticate the user by username + password. So far so good, but using the sample app for Windows8.1, I receive an exception in the Dispatcher class: public static void ExceuteAsync (Action action) { if (dispatcher.HasThreadAccess) >>>>this thrown an exception and I don't know where is the problem [...] Does anybody know what's the problem here? Many thanks in advance. Best wishes, Michael
asked Jan 23, 2017 in Windows by michaelbb (10 points)

2 Answers

0 votes
Hi Michael,

Could you please share the exception message you are getting? Also, share the code snippet which is producing this exception.

Thanks.
answered Jan 28, 2017 by rajeev.etc (1,660 points)
0 votes

Hi and thanks for the reply.

I get the following exception: NullReferenceException

Object Reference not set to an instance of an object

It occurs in the following class:

public class DISPATCHER
    {
        private static CoreDispatcher dispatcher;

        public static void Initialize()
        {
            dispatcher = Window.Current.Dispatcher;
        }

        public static void ExecuteAsync(Action action)
        {
            if (dispatcher.HasThreadAccess)
                action();

            else dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
        }

        public static void Execute(Action action)
        {
            InnerExecute(action).Wait();
        }

        private static async Task InnerExecute(Action action)
        {
            if (dispatcher.HasThreadAccess)
                action();

            else await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
        }

 

The exception error occurs in:

if (dispatcher.HasThreadAccess)

 

Many thanks in advance,

michael

answered Jan 30, 2017 by michaelbb (10 points)
Hi Michael,

Apologies for a late reply and It seems like the exception is not coming inside the user service and as you mentioned it is coming because of the dispatcher.HasThreadAccess. In this case,  I believe you have to report this issue on Windows forum or you can write to the public community like Stack overflow.

In case you face any difficulty while using App42 SDK, please feel free to let us know. We are happy to help you!

Also, I would suggest you can download App42 sample which have the user api integrated. Please download the sample from here(https://github.com/shephertz/App42_WINDOWS_SDK) and let us know if you face any issue.

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...