我目前正在尝试通过将文件链接到wpf库来将silverlight项目更改为wpf,以便以后可以同时使用这两个应用程序。我从silverlight项目链接到wpf项目的文件给我这个错误:
错误27类型或名称空间名称“部署”在名称空间“ System.Windows”中不存在(您是否缺少程序集引用?)C:\ Users \ sahluwai \ Desktop \ cusControls2 \ leitch \ HarrisSilverlightToolkit \ Toolkit \ Source \ Controls \ Input \ IpAddressControl \ CcsIPAddressControl.cs 854 36输入
我确保该文件的顶部具有“ using 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.Windows.Deployment
-专门针对Silverlight的调度程序。System.Windows.Application.Current.Dispatcher
如果您的意图是在属于GUI的Dispatcher上调用某些内容,请改用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句