Well, this doesn’t solve the problem. I get the same errors, but I can now trap them in code.
First off, my project is in VB.net. I’m fluent in both C# and VB so the conversion was not arduous. I’m posting it here so others may benefit and so your developers can review it for correctness.
Public Class ThreadSafeProj4Projection : Inherits Proj4Projection
Private Shared lockObject As Object = New Object()
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal internalProjectionParametersString As String, ByVal externalProjectionParametersString As String)
MyBase.New(internalProjectionParametersString, externalProjectionParametersString)
End Sub
Public Sub New(ByVal internalEpsgGrid As Integer, ByVal externalEpsgGrid As Integer)
MyBase.New(internalEpsgGrid, externalEpsgGrid)
End Sub
Protected Overrides Sub OpenCore()
SyncLock lockObject
MyBase.OpenCore()
End SyncLock
End Sub
Protected Overrides Sub CloseCore()
SyncLock lockObject
MyBase.CloseCore()
End SyncLock
End Sub
Protected Overrides Function ConvertToExternalProjectionCore(ByVal x() As Double, ByVal y() As Double) As Vertex()
Dim returnValue() As Vertex
SyncLock lockObject
returnValue = MyBase.ConvertToExternalProjectionCore(x, y)
End SyncLock
Return returnValue
End Function
Protected Overrides Function ConvertToInternalProjectionCore(ByVal x() As Double, ByVal y() As Double) As Vertex()
Dim returnValue() As Vertex
SyncLock lockObject
returnValue = MyBase.ConvertToInternalProjectionCore(x, y)
End SyncLock
Return returnValue
End Function
End Class
Second, I get an error in ConvertToInternalProjectionCore, within the SyncLock declaration, on
returnValue = MyBase.ConvertToInternalProjectionCore(x, y)
The error is:
System.Reflection.TargetInvocationException was unhandled by user code
Message=“Exception has been thrown by the target of an invocation.”
Source=“mscorlib”
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at ThinkGeo.MapSuite.Core.Proj4Projection.x95c4ca6342aad2f1(IntPtr xce536087faba9488, IntPtr x6d3e0b22c9356db3, Int64 x971ce686c8b74ac9, Double[] x31d531fc882737ba, Double[] x272f87fcdd19be88, Double[] xb5f5ca13f19c3e64)
at ThinkGeo.MapSuite.Core.Proj4Projection.ConvertToInternalProjectionCore(Double[] x, Double[] y)
at SMG.DMOE2.ThreadSafeProj4Projection.ConvertToInternalProjectionCore(Double[] x, Double[] y) in C:\Source\SMG\DMOE2\Web Source\DMOE\App_Code\MapHelpers.vb:line 157
at ThinkGeo.MapSuite.Core.Projection.ConvertToInternalProjection(RectangleShape rectangleShape)
at ThinkGeo.MapSuite.Core.FeatureSource.ConvertToInternalProjection(RectangleShape rectangle)
at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesInsideBoundingBox(RectangleShape boundingBox, IEnumerable`1 returningColumnNames)
at ThinkGeo.MapSuite.Core.FeatureSource.GetFeaturesInsideBoundingBox(RectangleShape boundingBox, ReturningColumnsType returningColumnNamesType)
at ThinkGeo.MapSuite.WebEdition.InMemoryMarkerOverlay.GetMarkersCore(RectangleShape worldExtent, Int32 currentZoomLevelId) at ThinkGeo.MapSuite.WebEdition.MarkerOverlay.GetMarkers(RectangleShape worldExtent, Int32 currentZoomLevelId)
at ThinkGeo.MapSuite.WebEdition.xc7cff1011d95a7ea.x3edbe401e632d8cc(MarkerOverlay x12602c8f059adbaf)
at ThinkGeo.MapSuite.WebEdition.xc7cff1011d95a7ea.x74301f6a6dff0247(HttpContext x367528c7f091a5d2)
at ThinkGeo.MapSuite.WebEdition.xc7cff1011d95a7ea.ProcessRequest(HttpContext context)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
InnerException: System.AccessViolationException
Message=“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
Source=“Proj4ExtensionX86”
StackTrace:
at Proj4Extension.Proj4Extensionx86.pj_transform(IntPtr srcCs, IntPtr destCs, Int64 pointCount, Double[] x, Double[] y, Double[] z)
at Proj4Extension.Proj4Extensionx86.Transform(IntPtr srcCs, IntPtr destCs, Int64 pointCount, Double[] x, Double[] y, Double[] z)
InnerException:
I suppose I could add a Try…Catch block to trap it, but what do I do with it? Once the memory is corrupt I assume things are pretty well hosed.
I was hoping this workaround would solve the problem. Honestly, this is now causing some issues for me with my client. It’s quite embarassing for me. Is there any word on when a fix will be released?
Bob Mc.