我目前正试图通过将文件链接到wpf librarys来将我的silverlight项目更改为wpf,以便以后我可以同时使用这两个应用程序。我链接到我的WPF项目从我的Silverlight项目这个文件是给我这个错误:命名空间'System.Windows'中不存在类型或命名空间名称'Deployment'
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
我已经确定该文件已经“使用System.Windows”排在首位。
这是什么功能的样子,其中有错误(请认准评论看一个例子出错位置):
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;
}
然后为委托里面我开始得到这个错误:**不能转换匿名方法键入'System.Delegate',因为它不是一个委托类型**是否有一个简单的解决方案呢? –
@SumitSingh你需要将匿名方法转换为委托,可能是'Action'。例如,''System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)delegate(){MessageBox.Show(“Hi”,“Error”,MessageBoxButton.OK);});' – vcsjones
是的。 –