The type or namespace name ‘Deployment’ does not exist in the namespace ‘System.Windows’
我目前正在尝试通过将文件链接到 wpf 库将我的 silverlight 项目更改为 wpf,以便以后我可以使用这两个应用程序。我从 silverlight 项目链接到我的 wpf 项目的这个文件给了我这个错误:
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”。
这是函数的样子,有错误(请查看注释以查看示例错误位置):
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
private bool ValidateIpOctet(TextBox IpOctet, int OctetIndex)
{ bool redraw = false; if (OctetIndex < 0 || OctetIndex >= this.m_IpAddress.IpOctets.Length) int i = OctetIndex; this.m_IpAddress.IpOctets[i] = String.IsNullOrEmpty(IpOctet.Text) ?“0” : IpOctet.Text; uint iOctet = uint.Parse(this.m_IpAddress.IpOctets[i]);
///////////////////////////////////////////////////////////////////////// System.Windows.Deployment.Current.Dispatcher.BeginInvoke( 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(); |
不要使用来自 System.Windows.Deployment 的调度程序 – 这是 Silverlight 特有的。如果您的意图是调用属于 GUI 的 Dispatcher 上的某些内容,请改用 System.Windows.Application.Current.Dispatcher。
- 然后对于内部的委托,我开始收到此错误:无法将匿名方法转换为类型 \\’System.Delegate\\’ 因为它不是委托类型是否也有简单的解决方法?
- @SumitSingh 您需要将匿名方法强制转换为委托,可能是 Action。例如,System.Windows.Application.Current.Dispatcher.BeginInvoke((A??ction)delegate () { MessageBox.Show(“Hi”,”Error”, MessageBoxButton.OK); });
来源:https://www.codenong.com/33636899/