This project is read-only.

DotSpatial.Positioning Error

Jan 23, 2012 at 7:22 PM

"The interpreter could not be started. Attempt by a security transparent method 'DotSpatial.Positioning.Interpreter.Start()' to access security critical method 'DotSpatial.Positioning.Devices.get_Any()' failed."

"Assembly 'DotSpatial.Positioning, Version=, Culture=neutral,PublicKeyToken=XXXXXXXXXXXX' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception."


Now, after reading many topics on this, I still cannot fix this issue. I have rebuilt the assembly without AllowPartiallyTrustedCallers attribute, and I have made multiple interpreter methods security critical. Nothing is seeming fix my problem.

If there are any suggestions, It would be more than appreciated.



Jan 24, 2012 at 9:47 AM


In order to eliminate errors such as the one you gave, I made the following changes to the Position code base. These changes are with reference to DotSpatial Release Candidate 3 (change set f2a48f88a0b3) source.


Add the attribute [SecuritySafeCritical] to:

        internal void Refresh()
            /* Attempt to populate information about this device, such as the name, and
             * whether the device is paired, connected, remembered, etc.

Change attribute [SecurityCritical] to [SecuritySafeCritical] on the class:
namespace DotSpatial.Positioning
    /// <summary>
    /// Encapsulates GPS device detection features and information about known devices.
    /// </summary>
    public static class Devices

Add the attribute [SecuritySafeCritical] to the class:
    public abstract class Interpreter : Component

and to the Dispose method:
        protected override void Dispose(bool disposing)

Add using clause vir System.Security and add attribute [SecuritySafeCritical] to class:
using System;
using System.Security;
using System.Text;

namespace DotSpatial.Positioning
    /// <summary>
    /// Represents an interpreter for GPS data from the National Marine Electronics Association (NMEA).
    /// </summary>
    public class NmeaInterpreter : Interpreter

I built the DotSpatial.Positioning.sln solution without any changes to the project or built properties and referenced the resulting DotSpatial.Positioning.dll in my application project as usual.
You may experience error in parsing the NmeaSentences generated by the NMEA emulator, I had to make the following changes to GpggaSentence.cs, GpggkSentence.cs, GpgllSentence.cs and GprmcSentence.cs
                LatitudeHemisphere latitudeHemisphere =
                    words[3].Equals("N", StringComparison.Ordinal) ? LatitudeHemisphere.North : LatitudeHemisphere.South;

                LatitudeHemisphere latitudeHemisphere =
                    words[3].IndexOf("N", StringComparison.Ordinal)!=-1 ? LatitudeHemisphere.North : LatitudeHemisphere.South;

                LongitudeHemisphere longitudeHemisphere =
                    words[5].Equals("E", StringComparison.Ordinal) ? LongitudeHemisphere.East : LongitudeHemisphere.West;

                LongitudeHemisphere longitudeHemisphere =
                    words[5].IndexOf("E", StringComparison.Ordinal)!=-1 ? LongitudeHemisphere.East : LongitudeHemisphere.West;

Jan 25, 2012 at 4:23 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 3, 2012 at 7:50 PM


This worked like a charm. Everything is working perfectly. Thank you so much. I hope these changes will be committed soon.

Best Regards,

Logan B. Lehman