-
Notifications
You must be signed in to change notification settings - Fork 129
WPF Design Time and Internet Security
If you download a Visual Studio solution (source code) from the Internet then you might see the following error message. This message comes from the WPF designer when you open a WPF Xaml view.
Xaml Design Window: Invalid Markup
Output Window (Show output from: General):
AppData\Local\Microsoft\VisualStudio\12.0\Designer\ShadowCache\ftaqb4jf.oxo\
i1wxe4ul.e2l\WpfApplicationFramework.dll
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.
The message is misleading because the Designer does not attempt to load an assembly from a network location. Instead, all files downloaded from the internet are marked by Windows as Blocked files. It seems that the WPF Xaml Designer is not able to load assemblies that were Blocked by Windows.
The blocked assemblies can be Unblocked by the Properties Window of the Windows Explorer.
However, every file has to be unblocked separately. If the downloaded source code consists of much files then unblocking with the Explorer is no fun at all. The PowerShell v3 introduced a command to unblock files. This way it is possible to unblock all files of a VS solution at once:
Get-ChildItem –recurse C:\Dev\FileHashGenerator | Unblock-File
Note: Windows 7 comes with PowerShell v2 which does not know this command. Microsoft provides a download to install PowerShell v3 on Windows 7.