2017-04-14 46 views
2

我加入了System.Net.Ping NuGet包到空白UWP項目和Mainpage.xaml.cs引用的System.Net.NetworkInformation命名空間。在UWP應用程序中使用System.Net.Ping - 2017年VS

在MainPage構造函數中,我只寫了Ping ping = new Ping()

編譯這個簡單的例子,一經推出引發此異常:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Ping, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. 
File name: 'System.Net.Ping, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 
    at App2.MainPage..ctor() 
    at App2.App2_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage() 
    at App2.App2_XamlTypeInfo.XamlUserType.ActivateInstance() 
    at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType, Object parameter) 
    at App2.App.OnLaunched(LaunchActivatedEventArgs e)} System.IO.FileNotFoundException 

的NuGet包System.Net.Ping目前在4.3.0版本和4.0.0可用,但是這兩個乖相同。

+0

當我嘗試重新編譯時,恢復失敗,說該軟件包沒有正確的UAP組件......這將解釋爲什麼沒有恢復,並且在運行時無法找到程序集。也許我對你的場景感到困惑? –

+0

發現此問題的任何解決方案? 我正在進入同樣的問題 - 安裝V 4.3.0,而異常是參考V 4.0.0 – Christoph

+0

@Christoph否,對不起。我最終沒有爲我的Szenario使用UWP。由於這本應該運行在帶有Windows 10 IoT核心的Raspberry Pi上,所以我能夠通過使用Raspbian來滿足我的需求。 – guyyst

回答

0

在這個答案的日期,類System.Net.NetworkInformation.Ping尚不支持UWP平臺。詳情請查詢this link

+0

呵呵,我完全忘記了在MSDN上也提出了同樣的問題,顯然沒有得到現在幾乎1歲的答案。 感謝您提醒我注意我猜:D – guyyst

+0

:-)其實我並不確定作者在兩篇文章中都是一樣的,所以我認爲在這裏分享答案也很有幫助。 –

0

嘗試增加參考System.Net.Utilities代替System.Net.Ping

+0

拋出幾乎完全相同的異常,僅使用'System.Net.Utilities'而不是'System.Net.Ping'。 – guyyst

相關問題