Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
dth #1
Member since Oct 2014 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: Problems to connect
Hi,

We have problems to connect with a server, this is the stacktrace:

Message: Unhandled Error in Silverlight Application
Code: 4004   
Category: ManagedRuntimeError      
Message: System.UnauthorizedAccessException: Invalid cross-thread access.
   at MS.Internal.XcpImports.CheckThread()
   at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, String s)
   at System.Windows.Threading.DispatcherTimer.set_Interval(TimeSpan value)
   at Matrix.XmppStream.?()
   at Matrix.XmppStream.?(Action ?)
   at Matrix.XmppStream.3q2mzyj4wtv734ttjnj6bnrw7kquujzy????(Object ?, EventArgs ?)
   at Matrix.Net.BaseSocket.FireOnConnect()
   at Matrix.Net.ClientSocket.?(Object ?, SocketAsyncEventArgs ?)
   at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.Socket.ConnectAsyncCallback(Object sender, SocketAsyncEventArgs args)
   at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
   at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)    

I don't have found anything about this. Can you help us?

Thank you.
The author has attached one file to this post:
pant.png 29.2 kBytes
You have no permission to open this file.
Avatar
Alex #2
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
System.UnauthorizedAccessException: Invalid cross-thread access.

this normally means that you try call non thread safe code from another thread.
For example when you update the UI which is not thread safe from a MatriX event which runs in another thread than your UI thread.

If this is the case you have to Invoke back on your Ui thread

  1. /// <summary>
  2. ///   Invokes the given action on the UI thread - if the current thread is the UI thread this will just invoke the action directly on
  3. ///   the current thread so it can be safely called without the calling method being aware of which thread it is on.
  4. /// </summary>
  5. public static void Invoke(Action action)
  6. {
  7.     if (Dispatcher.CheckAccess())
  8.         action.Invoke();
  9.     else
  10.         Dispatcher.BeginInvoke(action);
  11. }

When you set the Dispatcher of your UI in MatriX then all the MatriX events get invoked automatically for you.

  1. xmppClient.Dispatcher = myUiDispatcher;

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS