An exception of type 'System.IO.FileNotFoundException' occurred in xmppStart.exe but was not handled in user code
my code is given below [If it is not the way to connect server using xmpp pls let me know]
<pre>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Net.XMPP;
using System.Threading;
using Windows.UI.Popups;
namespace xmppStart
{
public sealed partial class MainPage : Page
{
public XMPPClient ObjXmppClient { get; set; }
public XMPPConnection ObjXmppCon { get; set; }
public string username = "sree";
public string password = "sree";
public readonly string server = "taurus";
private Boolean IsXmppSuccess { get; set; }
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
private void IsXmppValid()
{
//initializing the xmpp client with credentials
ObjXmppClient = new XMPPClient();
ObjXmppClient.JID = username + "@" + server;
ObjXmppClient.Password = password;
ObjXmppClient.Server = server; //user server for emulator and ip address for device.
ObjXmppClient.AutoReconnect = true;
ObjXmppClient.RetrieveRoster = true;
ObjXmppClient.PresenceStatus = new PresenceStatus() { PresenceType = PresenceType.available, IsOnline = true };
ObjXmppClient.AutoAcceptPresenceSubscribe = true;
ObjXmppClient.AttemptReconnectOnBadPing = true;
ObjXmppCon = new XMPPConnection(ObjXmppClient);
ObjXmppCon.Connect();
ObjXmppClient.Connect();
//initializing the xmpp connection
ObjXmppCon.OnAsyncConnectFinished += ObjXmppCon_OnAsyncConnectFinished;
ObjXmppClient.OnStateChanged += new EventHandler(xMPPClient_OnStateChanged);
}
void ObjXmppCon_OnAsyncConnectFinished(xmedianet.socketserver.SocketClient client, bool bSuccess, string strErrors)
{
IsXmppSuccess = client.Connected;
}
public async void xMPPClient_OnStateChanged(object sender, EventArgs e)
{
switch (ObjXmppClient.XMPPState)
{
case XMPPState.Ready:
if (IsXmppSuccess)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
Frame.Navigate(typeof(Logedin));
});
}
else
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
MessageDialog msgbox = new MessageDialog("Check server name/IpAddress");
});
}
break;
case XMPPState.AuthenticationFailed: await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
MessageDialog msgbox = new MessageDialog("Enter valid username and password");
return;
}); break;
}
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (txtname.Text == string.Empty)
{
MessageDialog msgbox = new MessageDialog("enter user name");
return;
}
if (txtpassword.Text == string.Empty)
{
MessageDialog msgbox = new MessageDialog("enter password");
return;
}
username = txtname.Text;
password = txtpassword.Text;
IsXmppValid();
}
}