Save Project

Nov 7, 2010 at 1:18 PM
Edited Nov 7, 2010 at 4:08 PM

When I load a shapefile in the testviewer and the try to save it as a project I get the following exception from the Dotspatial.Serialization.Serializationmap. I am running Win 7 64bit on a Dell I5 laptop. I get the message from the 32 and 64 bit Testviewer. As well when using the toolbar in a 2010 express app I get the same message.  

The conception of the software and the documentation are top notch but I cannot load or save files.



See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************System.TypeInitializationException: The type initializer for 'DotSpatial.Serialization.SerializationMap' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Developer\Dotspatial\x86\DotSpatial.Analysis.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> 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 for more information.   --- End of inner exception stack trace ---   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)   at System.Reflection.Assembly.LoadFrom(String assemblyFile)   at DotSpatial.Serialization.ReflectionHelper.FindDerivedClasses(Type baseType) in C:\Dev\DotSpatial\DotSpatial.Serialization\DotSpatial.Serialization\ReflectionHelper.cs:line 64   at DotSpatial.Serialization.SerializationMap..cctor() in C:\Dev\DotSpatial\DotSpatial.Serialization\DotSpatial.Serialization\SerializationMap.cs:line 54   --- End of inner exception stack trace ---   at DotSpatial.Serialization.SerializationMap.FromType(Type type)   at DotSpatial.Serialization.XmlSerializer.WriteValue(String elementName, SerializeAttribute serializeAttribute, Object value, Object[] content) in C:\Dev\DotSpatial\DotSpatial.Serialization\DotSpatial.Serialization\XmlSerializer.cs:line 144   at DotSpatial.Serialization.XmlSerializer.Serialize(Object value) in C:\Dev\DotSpatial\DotSpatial.Serialization\DotSpatial.Serialization\XmlSerializer.cs:line 64   at DotSpatial.Controls.SpatialToolStrip.cmdSave_Click(Object sender, EventArgs e) in C:\Dev\DotSpatial\DotSpatial.Controls\DotSpatial.Controls\SpatialToolStrip.cs:line 514   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)   at System.Windows.Forms.Control.WndProc(Message& m)   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)   at System.Windows.Forms.ToolStrip.WndProc(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************mscorlib    Assembly Version:    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll----------------------------------------TestViewer    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/TestViewer.exe----------------------------------------System.Windows.Forms    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll----------------------------------------System.Drawing    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll----------------------------------------System    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll----------------------------------------DotSpatial.Controls    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Controls.DLL----------------------------------------DotSpatial.Symbology    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Symbology.DLL----------------------------------------DotSpatial.Topology    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Topology.DLL----------------------------------------DotSpatial.Data    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Data.DLL----------------------------------------DotSpatial.Data.Forms    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Data.Forms.DLL----------------------------------------DotSpatial.Symbology.Forms    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Symbology.Forms.DLL----------------------------------------System.Core    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll----------------------------------------DotSpatial.Serialization    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Serialization.DLL----------------------------------------System.Data    Assembly Version:    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll----------------------------------------System.Xml    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll----------------------------------------DotSpatial.Modeling.Forms    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Modeling.Forms.DLL----------------------------------------System.Numerics    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll----------------------------------------DotSpatial.Projections    Assembly Version:    Win32 Version:    CodeBase: file:///C:/Developer/Dotspatial/x86/DotSpatial.Projections.DLL----------------------------------------System.Xml.Linq    Assembly Version:    Win32 Version: 4.0.30319.1 built by: RTMRel    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll----------------------------------------
************** JIT Debugging **************To enable just-in-time (JIT) debugging, the .config file for thisapplication or computer (machine.config) must have thejitDebugging value set in the section.The application must also be compiled with debuggingenabled.
For example:
<configuration>    < jitDebugging="true" /></configuration>
When JIT debugging is enabled, any unhandled exceptionwill be sent to the JIT debugger registered on the computerrather than be handled by this dialog box.

Nov 7, 2010 at 5:10 PM
The fix listed seems to involve modifying the "config" file:

<loadFromRemoteSources enabled="true"/>

Our project serialization, apps, data extensions and tools all require the ability to access assemblies that are not directly referenced by the project. If you are running in an internet context with version 3.5 or earlier in an internet context, the assemblies will automatically be sandboxed in a partial trust environment. So it looks like you have 3 options.

1) Set the flag above and run in full trust in 4.0 (Easy to do but full trust is not available from every hosting company).
2) switch the target framework of our source files to 3.5 and build all, using version 3.5 release. (not recommended).
3) Learn what in the world they are talking about by a "Sandbox" and setup the project to run in the sandbox explicitly.

Don't ask me how to do the last option. To me a sandbox is something that kids play in and that eventually gets removed once their parents learn that stray cats use it like a litter box.


P.S. Let me know if we have to mark the solution itself with .Net attributes to make this thing work better. For now it looks like its something that resides in the web developers court, rather than in our solution.
Nov 7, 2010 at 7:22 PM

I don't know if this will help but there here is some stuff from Microsoft. There are links at the bottom that may also be of interest;k(TargetFrameworkMoniker-%22.NETFRAMEWORK,VERSION%3dV4.0%22)&rd=true

Code Access Security for ClickOnce Applications

Visual Studio 2010


ClickOnce applications are based on the .NET Framework and are subject to code access security constraints. For this reason, it is important that you understand the implications of code access security and write your ClickOnce applications accordingly.

Code access security is a mechanism in the .NET Framework that helps limit the access that code has to protected resources and operations. You should configure the code access security permissions for your ClickOnce application to use the zone appropriate for the location of the application installer. In most cases, you can choose the Internet zone for a limited set of permissions or the Local Intranet zone for a greater set of permissions.

Default ClickOnce Code Access Security

By default, a ClickOnce application receives Full Trust permissions when it is installed or run on a client computer.

  • An application that has Full Trust permissions has unrestricted access to resources such as the file system and the registry. This potentially allows your application (and the end user's system) to be exploited by malicious code.

  • When an application requires Full Trust permissions, the end user may be prompted to grant permissions to the application. This means that the application does not truly provide a ClickOnce experience, and the prompt can potentially be confusing to less experienced users.


    When installing an application from removable media such as a CD-ROM, the user is not prompted. In addition, a network administrator can configure network policy so that users are not prompted when they install an application from a trusted source. For more information, see Trusted Application Deployment Overview.

To restrict the permissions for a ClickOnce application, you can modify the code access security permissions for your application to request the zone that best fits the permissions that your application requires. In most cases, you can select the zone from which the application is being deployed. For example, if your application is an enterprise application, you can use the Local Intranet zone. If your application is an internet application, you can use the Internet zone.

Configuring Security Permissions

You should always configure your ClickOnce application to request the appropriate zone to limit the code access security permissions. You can configure security permissions on the Security page of the Project Designer.

The Security page in the Project Designer contains an Enable ClickOnce Security Settings check box. When this check box is selected, security permission requests are added to the deployment manifest for your application. At installation time, the user will be prompted to grant permissions if the requested permissions exceed the default permissions for the zone from which the application is deployed. For more information, seeHow to: Enable ClickOnce Security Settings.

Applications deployed from different locations are granted different levels of permissions without prompting. For example, when an application is deployed from the Internet, it receives a highly restrictive set of permissions. When installed from a local Intranet, it receives more permissions, and when installed from a CD-ROM, it receives Full Trust permissions.

As a starting point for configuring permissions, you can select a security zone from theZone list on the Security page. If your application will potentially be deployed from more than one zone, select the zone with the least permissions. For more information, see How to: Set a Security Zone for a ClickOnce Application.

The properties that can be set vary by permission set; not all permission sets have configurable properties. For more information about the full list of permissions that your application can request, see System.Security.Permissions. For more information about how to set permissions for a custom zone, see How to: Set Custom Permissions for a ClickOnce Application.

Debugging an Application That Has Restricted Permissions

As a developer, you most likely run your development computer with Full Trust permissions. Therefore, you do not see the same security exceptions when you debug the application that users may see when they run it with restricted permissions.

In order to catch these exceptions, you have to debug the application with the same permissions as the end user. Debugging with restricted permissions can be enabled on theSecurity page of the Project Designer.

When you debug an application with restricted permissions, exceptions will be raised for any code security demands that have not been enabled on the Security page. An exception helper will appear, providing suggestions about how to modify your code to prevent the exception.

In addition, when you write code, the IntelliSense feature in the Code Editor will disable any members that are not included in the security permissions that you have configured.

For more information, see How to: Debug a ClickOnce Application with Restricted Permissions.

Security Permissions for Browser-Hosted Applications

Visual Studio provides the following project types for Windows Presentation Foundation (WPF) applications:

  • WPF Windows Application

  • WPF Web Browser Application

  • WPF Custom Control Library

  • WPF Service Library

Of these project types, only WPF Web Browser Applications are hosted in a Web browser and therefore require special deployment and security settings. The default security settings for these applications are as follows:

  • Enable ClickOnce Security Settings

  • This is a partial trust application

  • Internet zone (with default permission set for WPF Web Browser Applications selected)

In the Advanced Security Settings dialog box, the Debug this application with the selected permission set check box is selected and disabled. This is because Debug In Zone cannot be turned off for browser-hosted applications. For more information, see WPF XAML Browser Applications Overview.