Opened 13 years ago

Closed 13 years ago

#3699 closed defect (fixed)

AccessViolation Exception when calling mapObj.processQueryTemplate through C# mapscript rapper

Reported by: jnccfelix Owned by: tamas
Priority: normal Milestone: 6.0 release
Component: MapScript-C# Version: svn-trunk (development)
Severity: normal Keywords:
Cc:

Description

I am trying to implement handling of WMS getfeatureinfo requests using mapserver. Further details of the actually what I am attempting to do are in this question on stack overflow.

http://stackoverflow.com/questions/5041566/how-to-process-layer-templates-using-mapscript-to-respond-to-a-wms-getfeatureinfo

When I call processQueryTemplate I get an ArgumentException as follows

System.AccessViolationException was unhandled

Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=mapscript_csharp StackTrace:

at OSGeo.MapServer.mapscriptPINVOKE.mapObj_processQueryTemplate(HandleRef jarg1, IntPtr[] jarg2, IntPtr[] jarg3, Int32 jarg4) at OSGeo.MapServer.mapObj.processQueryTemplate(String[] names, String[] values, Int32 numentries) at bars.web.mapserver.MapFactory.GetFeatureInfoFromWMS(NameValueCollection WMSqueryString) in C:\Development\BARS - trunk\bars.web.mapserver\MapFactory.cs:line 278 at bars.web.application.Controllers.MapController.GetFeatureInfo() in C:\Development\BARS - trunk\bars.web.ui.application\Controllers\MapController.cs:line 71 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>cDisplayClass15.<InvokeActionMethodWithFilters>b12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>cDisplayClass15.<>cDisplayClass17.<InvokeActionMethodWithFilters>b14() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.<>cDisplayClass6.<>cDisplayClassb.<BeginProcessRequest>b5() at System.Web.Mvc.Async.AsyncResultWrapper.<>cDisplayClass1.<MakeVoidDelegate>b0() at System.Web.Mvc.Async.AsyncResultWrapper.<>cDisplayClass8`1.<BeginSynchronous>b7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.MvcHandler.<>cDisplayClasse.<EndProcessRequest>bd() at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b0(Action f) at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr) at System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr) at Microsoft.VisualStudio.WebHost.Request.Process() at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn) at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn) at Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(Object acceptedSocket) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

InnerException:

It is very possible that I am not using the method appropriately or there is some aspect of the environment in which the call is made that is incorrect however I would not expect this type exception to be thrown, rather I would expect something meaningful that explains the reason for the failure of the call.

There is info about the specific code in the stack overflow question mentioned above but I will also add the full class that I am using here and the mapfile - I should point out that the code to render the map works fine just this getfeatureinfo implementation isn't working well.

Attachments (2)

MapFactory.cs (16.1 KB ) - added by jnccfelix 13 years ago.
C# class that makes handles incoming WFS map and getfeatureinfo requests
TESTMAPFILE.map (9.5 KB ) - added by jnccfelix 13 years ago.
mapfile - some elements are tokenised - ie plugin paths and datafilters - these are replaced in the layer definitions by mapfactory

Download all attachments as: .zip

Change History (5)

by jnccfelix, 13 years ago

Attachment: MapFactory.cs added

C# class that makes handles incoming WFS map and getfeatureinfo requests

by jnccfelix, 13 years ago

Attachment: TESTMAPFILE.map added

mapfile - some elements are tokenised - ie plugin paths and datafilters - these are replaced in the layer definitions by mapfactory

comment:1 by tamas, 13 years ago

I suspect the problem is related to the incorrect value for the numentries parameter. Only 1 element have been specified in the arrays so it should be:

string[] names = { "Token1" }; string[] values = { "Value1" }; output = map.processQueryTemplate(names, values, 1);

comment:2 by tamas, 13 years ago

Added argument check and changed the signature to:

public string processTemplate(int bGenerateImages, string[] names, string[] values) public string processLegendTemplate(string[] names, string[] values) public string processQueryTemplate(string[] names, string[] values)

in MapServer 6.0 (r11081)

comment:3 by tamas, 13 years ago

Milestone: 6.0 release
Resolution: fixed
Status: newclosed
Version: unspecifiedsvn-trunk (development)

Closing the ticket for now

Note: See TracTickets for help on using tickets.