DotSpatial.Positioning Error

Jan 23, 2012 at 6: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=0.11.9.6, 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.

Thanks,

Logan

Jan 24, 2012 at 8:47 AM

Logan,

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.

BluetoothDevice.cs:

Add the attribute [SecuritySafeCritical] to:

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

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

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

and to the Dispose method:
 
        [SecuritySafeCritical]
        protected override void Dispose(bool disposing)
        {

NmeaInterpreter.cs
 
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>
    [SecuritySafeCritical]
    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
 
Change:
 
                LatitudeHemisphere latitudeHemisphere =
                    words[3].Equals("N", StringComparison.Ordinal) ? LatitudeHemisphere.North : LatitudeHemisphere.South;

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

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

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

 
 
 Regards
Kobus
 
Developer
Jan 25, 2012 at 3: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 6:50 PM

Kobus,

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