Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Here i am trying to develop a chat app using xmpp and openfire server in windows phone 8.1.when i am trying to connect with openfire server it showing this error.i tried out many ways but no result and i cannot understand too..(i added username and password in server)

this part am getting error-
ObjXmppClient = new XMPPClient();

An exception of type 'System.IO.FileNotFoundException' occurred in xmppStart.exe but was not handled in user code

Additional information: Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.


my code is given below [If it is not the way to connect server using xmpp pls let me know]

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();
        }
    }
}
Posted
Updated 30-Sep-15 20:18pm
v3
Comments
Sinisa Hajnal 1-Oct-15 2:35am    
How about putting a breakpoint and/or try..catch block and seeing in detail what is happening? You'll get a stacktrace that way.
[no name] 1-Oct-15 3:06am    
yes.when i put breakpoint,stuk their and showing the same error.in try catch also showing this error

Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
Richard MacCutchan 1-Oct-15 4:41am    
Some part of the .NET framework is missing from your system. The error message explains the details.
[no name] 1-Oct-15 5:24am    
how can i find out that part? even i didnt get a solution from google

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900