错误WiFi WP7模拟器

时间:2012-04-06 09:20:51

标签: c# windows-phone-7

Error WiFi

当我尝试连接@IP(本地)时出现此错误。 它是一个套接字(tcp& udp)。 我使用模拟器 如果在WP7仿真器上有激活WiFi的代码? 或者我可能会停用WiFi连接

这个我添加连接的代码都可以使用它

private void AddComputer_Click(object sender, RoutedEventArgs e)
    {
        IPAddress iPAddress;
        if (!IPAddress.TryParse(this.IPAddressTextBox.Text, out iPAddress))
        {
            MessageBox.Show("Error: Invalid IP Address is empty");
            return;
        }
        this.ipAddressToAdd = iPAddress;
        this.progressBar.IsIndeterminate = true;
        this.StatusTextBlock.Visibility=(Visibility)0;
        this.ContentPanel.Visibility=(Visibility)1;
        ThreadPool.QueueUserWorkItem(new WaitCallback(this.AddComputerThread), new NetworkHandler.DiscoveredServer("", this.ipAddressToAdd, false, "", this.checkBoxPassword.IsChecked.Value, this.passwordBox1.Password, NetworkHandler.NetworkCategory.Unknown));
    }
    private void AddComputerThread(object obj)
    {
        NetworkHandler.DiscoveredServer info = (NetworkHandler.DiscoveredServer)obj;
        NetworkHandlerCommon.ConnectResult connectResult = ConnectionHandler.ConnectToComputer(info, true, MyApp.MajorVersion, MyApp.MinorVersion);
        base.Dispatcher.BeginInvoke(delegate
        {
            this.AddComputerDispatcher(connectResult);
        }
        );
    }
    private void AddComputerDispatcher(NetworkHandlerCommon.ConnectResult connectResult)
    {
        this.progressBar.IsIndeterminate = false;
        this.StatusTextBlock.Visibility=(Visibility)1;
        this.ContentPanel.Visibility=(Visibility)0;
        if (connectResult == NetworkHandlerCommon.ConnectResult.Connected)
        {
            base.NavigationService.Navigate(MyApp.HomePage());
            return;
        }
        this.ShowConnectError(connectResult);
    }
    private void ShowConnectError(NetworkHandlerCommon.ConnectResult result)
    {
        switch (result)
        {
            case NetworkHandlerCommon.ConnectResult.UpdateServer:
                ErrorHandler.ShowErrorMessage(1003);
                return;

            case NetworkHandlerCommon.ConnectResult.UpdateClient:
                ErrorHandler.ShowErrorMessage(1002);
                return;

            case NetworkHandlerCommon.ConnectResult.Failed:
                ErrorHandler.ShowErrorMessage(1005);
                return;

            case NetworkHandlerCommon.ConnectResult.AuthenticationFailure:
                MessageBox.Show("Error: Password is incorrect.");
                return;

            case NetworkHandlerCommon.ConnectResult.NetworkNotConnected:
                MainPage.ShowNetworkDisconnectedMessage();
                return;

            default:
                return;
        }
    }

并且此类显示如果为真,则会发生错误

public class ErrorHandler
{
    private class ErrorInfo
    {
        public string ErrorMessage
        {
            get;
            set;
        }
        public string ErrorURL
        {
            get;
            set;
        }
        public ErrorInfo(string errorMessage, string errorURL)
        {
            this.ErrorMessage = errorMessage;
            this.ErrorURL = errorURL;
        }
    }
    private static Dictionary<int, ErrorHandler.ErrorInfo> errorMapping;
    static ErrorHandler()
    {
        ErrorHandler.errorMapping = new Dictionary<int, ErrorHandler.ErrorInfo>();
        ErrorHandler.errorMapping.Add(1000, new ErrorHandler.ErrorInfo("Error 1000: We have detected that WiFi is NOT turned-on at your phone.", "http://wp.me/p1ZVRQ-w"));
        ErrorHandler.errorMapping.Add(1001, new ErrorHandler.ErrorInfo("Error 1001: Password is incorrect.", "http://wp.me/p1ZVRQ-E"));
        ErrorHandler.errorMapping.Add(1002, new ErrorHandler.ErrorInfo("Error 1002: Older version of application is running. Update application from Marketplace.", "http://wp.me/p1ZVRQ-H"));
        ErrorHandler.errorMapping.Add(1003, new ErrorHandler.ErrorInfo("Error 1003: Older version of PC Remote server is running at PC", "http://wp.me/p1ZVRQ-K"));
        ErrorHandler.errorMapping.Add(1004, new ErrorHandler.ErrorInfo("Error 1004: Computer is connected to a public network", "http://wp.me/p1ZVRQ-d"));
        ErrorHandler.errorMapping.Add(1005, new ErrorHandler.ErrorInfo("Error 1005: Failed connecting to your PC", "http://wp.me/p1ZVRQ-j"));
        ErrorHandler.errorMapping.Add(1006, new ErrorHandler.ErrorInfo("Error 1006: Could not wake up your computer", "http://wp.me/p1ZVRQ-S"));
        ErrorHandler.errorMapping.Add(1007, new ErrorHandler.ErrorInfo("Error 1007: Unable to resume the app.", "http://wp.me/p1ZVRQ-W"));
    }
    public static void ShowErrorMessage(int errorId)
    {
        if (ErrorHandler.errorMapping.ContainsKey(errorId))
        {
            ErrorHandler.ErrorInfo errorInfo = ErrorHandler.errorMapping[errorId];
            string text = errorInfo.ErrorMessage + Environment.NewLine + Environment.NewLine + "Need help troubleshooting this? ";
            if (MessageBox.Show(text, "Error", MessageBoxButton.OKCancel).Equals(1))
            {
                MyApp.GoToWebURL(errorInfo.ErrorURL);
            }
        }
    }
}

0 个答案:

没有答案