2
votes

I am currently trying to change my silverlight project to to wpf by linking files to wpf librarys so that later i can use both the applications. This file which i linked to my wpf project from my silverlight project is giving me this error:

Error 27 The type or namespace name 'Deployment' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) C:\Users\sahluwai\Desktop\cusControls2\leitch\HarrisSilverlightToolkit\Toolkit\Source\Controls\Input\IpAddressControl\CcsIPAddressControl.cs 854 36 Input

I have made sure that the file has "using System.Windows" at the top.

This is what function looks like ,which has errors(please look for the comment to see an example error location):

private bool ValidateIpOctet(TextBox IpOctet, int OctetIndex)
    {
        bool redraw = false;

        if (OctetIndex < 0 || OctetIndex >= this.m_IpAddress.IpOctets.Length)
            return redraw;

        int i = OctetIndex;

        this.m_IpAddress.IpOctets[i] = String.IsNullOrEmpty(IpOctet.Text) ? "0" : IpOctet.Text;

        uint iOctet = uint.Parse(this.m_IpAddress.IpOctets[i]);
        if (i == 0)
        {
            if (Rule == NetworkInterfaceRule.IP || Rule == NetworkInterfaceRule.GATEWAY)
            {
                if (iOctet > 223)
                {
                    redraw = true;
                    this.m_IpAddress.IpOctets[i] = "223";
                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                        delegate()
                        {
                            MessageBox.Show(String.Format("{0} is not a valid entry. Please specify a value between 1 and 223.", this.IpAddress), "Error", MessageBoxButton.OK);
                        });
                }
                else if (iOctet < 1)
                {
                    redraw = true;
                    this.m_IpAddress.IpOctets[i] = "1";
                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                        delegate()
                        {
                            MessageBox.Show(String.Format("{0} is not a valid entry. Please specify a value between 1 and 223.", this.IpAddress), "Error", MessageBoxButton.OK);
                        });
                }
            }
            else
            {
                if (iOctet > 255)
                {
                    redraw = true;
                    this.m_IpAddress.IpOctets[i] = "255";


 /////////////////////////////////////////////////////////////////////////
 //////////////////////this is one place where i am facing this error:

                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                        delegate()
                        {
                            MessageBox.Show(String.Format("{0} is not a valid entry. Please specify a value between 0 and 255.", this.IpAddress), "Error", MessageBoxButton.OK);
                        });
                }
                else if (iOctet < 0)
                {
                    redraw = true;
                    this.m_IpAddress.IpOctets[i] = "0";
                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                        delegate()
                        {
                            MessageBox.Show(String.Format("{0} is not a valid entry. Please specify a value between 0 and 255.", this.IpAddress), "Error", MessageBoxButton.OK);
                        });
                }
            }
        }
        else
        {
            if (iOctet > 255)
            {
                redraw = true;
                this.m_IpAddress.IpOctets[i] = "255";
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                    delegate()
                    {

                        MessageBox.Show(String.Format("{0} is not a valid entry. Please specify a value between 0 and 255.", this.IpAddress), "Error", MessageBoxButton.OK);
                    });
            }
            else if (iOctet < 0)
            {
                redraw = true;
                this.m_IpAddress.IpOctets[i] = "0";
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(
                    delegate()
                    {
                        MessageBox.Show(String.Format("{0} is not a valid entry. Please specify a value between 0 and 255.", this.IpAddress), "Error", MessageBoxButton.OK);
                    });
            }
        }

        this.IpAddress = this.m_IpAddress.ToString();
        return redraw;
    }
1

1 Answers

2
votes

Don't use the dispatcher from System.Windows.Deployment - that's specific to Silverlight. Use System.Windows.Application.Current.Dispatcher instead if your intent is to invoke something on the Dispatcher that belongs to the GUI.