網站下載程式碼後無法編譯
0 |
從CodePlex下載SourceCode回家玩,Build時卻發生錯誤:
The "ValidateXaml" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\WorkRoom\WP7\3rdParty\PhoneControls\Phone.Controls.Samples.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\WorkRoom\WP7\3rdParty\PhoneControls\Phone.Controls.Samples.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
由訊息研判,發生錯誤的原因是Phone.Controls.Samples.dll來自網路下載,故不被信任。(事實上這個dll是從下載的ZIP檔解壓縮取出的,沒想到.NET Framework/Windows 7這麼精,沒有良民證的事還是一下就被揪出來 XD)
解法很簡單,用檔案總管將DLL上的封印解除即可: (Unblock的技巧先前有介紹過)
【延伸閱讀】
MSDN: How to: Use an Assembly from the Web in Visual Studio
PS: MSDN的社群註解(Community Content)功能挺不賴的,在其中看到一則網友回饋的小提示: 下載包含DLL的ZIP檔時,先將ZIP Unblock,就不需要解出一堆DLL再一一Unblock囉!
Comments
Be the first to post a comment