ThinkGeo.com    |     Documentation    |     Premium Support

Parameter is not valid - Excpetions

ParameterNotValidExceptions.pdf (144.0 KB)MapSuite Team,

My application continues to encounter “Parameter is not valid” from LayerOverlay & FeatureLayer Drawing & Drawn exceptions. I have attached a spreadsheet that shows the sequence of events during one of these episodes. These ultimately lead to an Out-of-Memory condition causing the application to terminate.

Also in the spreadsheet are the Overlay characteristics.

I should point out that some of the layers are ShapeFileFeatureLayer and some are SQLiteFeatureLayer with a total of 68 layers. Each of the LayerOverlay have a combination of ShapeFileFeatureLayer and SQLiteFeatureLayer.

Would you consider it a problem that the Overlay’s and FeatureLayer are mixed as I’ve stated?

Would you advise that all the layers should be either SQLiteFeatureLayer or ShapefileFeatureLayer? Or at least all ShapefileFeatureLayer on one LayerOverlay and all SQLiteFeatureLayer on the other LayerOverlay.

Thanks,
Dennis

Hi Dennis,

I think how to put your layer into overlay is not related with the exception.

But for make it handle better, if possible you can put the same type feature layer in one overlay.

Thanks for your pdf, but we cannot find the reason only from the exception message: Parameter is not valid.

Could you reproduce that when you debug it?

If you can trace the exception when debug, could you please provide us more detail exception information?

And it looks your pdf mentioned tile size, we suggest you use the same tile size in one map, but that’s not important problem.

Regards,

Don

Don,

The exception of “Parameter not valid.” is encountered within the MapSuite DLL’s and returned to my application because I have defined the event handlers:

        TheFeatureLayer.DrawnException       += new EventHandler<DrawnExceptionLayerEventArgs>   (FeatureLayer_DrawnException  );
        TheFeatureLayer.DrawingException    += new EventHandler<DrawingExceptionLayerEventArgs>(FeatureLayer_DrawingException);

So even if I was in debug mode that’s not going to tell me anything because the exception is actually in MapSuite code. I get the description of the exception “Parameter not valid.”, when the event is raised, from:

        DrawnExceptionLayerEventArgs e.Exception.Message

I believe it is the MapSuite code that should populate Exception.Message with more details, specifically from what piece of code did the exception emanate and any other useful information.

Also, I am not able to at will reproduce this exception. I am convinced this is a timing issue when MultipleTile is specified for LayerOverlay. And in my condition when there are two LayerOverlay with mixed FeatureLayer Types spread amongst them. In fact I have never been able to reproduce this exception. It is only encountered in a live production environment. My application serves a public emergency call center so the map is very busy with users zooming in/out, panning, and changing extents at a rapid pace.

Regards,
Dennis

Hi Dennis,

It looks “Parameter not valid” is not the custom exception in our code, it should thrown from some system class. So it’s hard to locate where is the problem when we debug it.

Just like you said, in debug mode we hadn’t reproduced it, so I think we still need to try to get more detail information about that and guess where is the possible problem.

I read the code of DrawnException, the parameter Exception is a system class, so please don’t only save the e.Exception.Message, could you please save other information like StackTrace, InnerException, Source etc., so maybe we can find some more useful information from it.

Regards,

Don

hi Don,

It was hard to read the spreadsheet as a PDF, but in the PDF was the final .NET logging from the application crashing, which is below. Notice that it has “system.drawing” and that’s when this is occurring, on a draw.

Yes, I agree, this is an exception encountered down in .NET and then bubbled-up to MapSuite and then to my application.

Also on the Drawn & Drawing Exceptions the below is encountered intermittingly and sometimes coupled with “Parameter is not valid.”.
“Collection was modified; enumeration operation may not execute.”

In the meantime what I did was to place all Feature Layers (Shape File & SQLite) on one LayerOverlay configured as SingleTile. I installed this configuration on five production workstations. They have been running now for over 24 hours and not one problem has been encountered.

I would like to get these exceptions resolved so will modify my code in an attempt to capture all of what is in Exception. I will get this done in a day or two, install it on a few workstations and capture the logs for you.

Regards,
Dennis

EventType clr20r3, P1 viewofchicago.exe, P2 1.0.0.0, P3 575ed068, P4 system.drawing, P5 4.0.0.0, P6 5073c7ec, P7 42c, P8 2c, P9 system.outofmemoryexception, P10 NIL.

Exception Info: System.OutOfMemoryException
Stack:
at System.Drawing.Graphics.CheckErrorStatus(Int32)
at System.Drawing.Graphics.DrawImage(System.Drawing.Image, Int32, Int32)
at ThinkGeo.MapSuite.Core.GdiPlusGeoCanvas.EndDrawingCore()
at ThinkGeo.MapSuite.WpfDesktopEdition.Tile.phc=(System.Object)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Hi Dennis,

Thanks for your test, so it looks if you set single tile mode, the exception disappear. Then I will try to look into multiply mode related class and see whether that’s related with multi-thread.

You attached an exception OutOfMemory, does that been thrown for single tile mode or another exception for multiply tile mode?

Regards,

Don

hi Don,

The exception I attached was the final result of all those “Parameter is not valid” exceptions when using MultipleTile.

Dennis

Hi Dennis,

It seems like a drawing issue, it can be referred to

But I can’t reproduce this issue.

From your stack information, I can see the exception has been thrown by multi-thread drawing, but I don’t know which feature layer thrown this exception, I think you can create new feature layer classes which are inherited from ShapeFileFeatureLayer or SqliteFeatureLayer so that I can get the throwing exception class name, such as following statements:

    public class CustomizedShapeFileFeatureLayer : ShapeFileFeatureLayer
{
    protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
    {
        try
        {
            base.DrawCore(canvas, labelsInAllLayers);
        }
        catch(Exception ex)
        {
            Debug.WriteLine(ex.Message);
            Debug.WriteLine(this.Name);
        }
    }
}

If you get more information, you can send it to me.

Thanks,

Don,

I’ve not been receiving the typical ThinkGeo emails when you’ve been updating this thread so I missed this last one. The errors occur on Shape Files as well as SQLite, and MrSid. If you refer to my original spreadsheet it has this information.

As you requested I modified my application to gather additional information. Attached is a text file with more information that occurred on an exception of
“Collection was modified; enumeration operation may not execute.”

Dennis
CollectionWasModified.txt (5.2 KB)

Hi Dennis,

Thanks for your test data.

It looks all the exception is thrown from the shape file feature layer. And the message shows collection was modified.

I viewed the code follow the exception track, I guess that’s maybe because the customStyles for zoomlevel had been modified when the application is running. Could you please double check you code and see whether your project will dynamic modify the custom style, if you used the custom style, could you please tried to use default style and see whether this exception will be thrown again? Which should be helpful for us find where is the issue.

Regards,

Don

hi Don,

Attached is an episode of “Parameter is not valid.” exceptions with the full logging of the exception so it really shows a lot more information.

Also attached are two screen captures of the map. One shows MrSid Visible and Building Addresses Visible. The other has MrSid InVisible with Building Addresses and Building Polygon filled. In order to accomplish whether the building fill is present the ValueStyles are changed depending on whether the MrSid is Visible or InVisible. I had asked in another post long time ago if there was another way to accomplish this and I believe the answer was no. What is your suggestion about using the DefaultStyle?

I can’t be the only one who styles their map in this fashion. How do other people do this without running into these threading issues?

What this situation calls for is really the .NET Binding design. Where ValueStyles would have a Binding to a property that in my case would indicate whether MrSid is displayed or not.

I’ve seen the “Parameter is not valid” once in SingleTile because I still have two overlays, one for all the Feature Layers and the other for the MrSid’s.

I really need to find a solution because my users don’t like SingleTile and they want to go back to MultipleTile. I also prefer how MultipleTile draws.

Thanks,
Dennis

ParameterIsNotValidExtentedLogging.txt (45.0 KB)

Hi Dennis,

I want to help you fixed that, but just like you known, we can just “guess” where is the problem because we cannot debug it, so the progress won’t get very fast.

Thanks for your error information today, I found that different exceptions today than yesterday.

The exception should because when the layer draw via GdiplusRasterLayer, the beginDrawing function passed into invalid width and height. From our code I cannot found where is the problem but maybe override drawCore for your layer can print canvas.width and canvas.height, one of them should be invalid when the exception is thrown. For multiply tile mode, the “Parameter is not valid.” should because the width&height invalid for tile. But I also cannot make sure what’s the status will make they are invalid. I have a question here, if the code thrown “Parameter is not valid.” whether you can get any special behavior from map? For example pink tile.

For your first question, I know someone need to switch between some different layer, I think they keep put them in different overlay, if one overlay is shown, the other should be invisible, but why this operation will make exception?

Regards,

Don

hi Don,

I understand about ‘guessing’ where the problems I’ve been there before.

I did notice today one map where the entire extent was overlaid with an opaque pink color with the MrSid and other layers still visible under the pink . The pink would not go away even if you changed the extent. The application was experiencing the “Parameter is not valid” exception. Had to stop/start the application in order to get it working properly again.

Another piece of information for you is that our display monitors are 22 inch wide-screen 1680x1050 resolution. Thought this might be useful since you’re seeing an invalid height and/or width. The TileSize for the MrSid LayerOverlay is 512x512. Do you think maybe the width/height is not being calculated properly under certain conditions given the monitor resolution and TileSize? Or because the MrSid LayerOverlay TileSize is 512x512 and the Feature Layer LayerOverlay TileSize is 1024x1024?

I had previously implemented an adapted version of your MultiGeoRasterLayer in my application. So I already override the DrawCore, but these exceptions are not coming from there. I’ll look at making some changes where I can capture the Canvas Height/Width when the exception is encountered.

Your assistance is greatly appreciated.

Dennis

Don,

Attached is an OutOfMemoryException and where the application crashed due to a system.drawing.

Dennis
OutOfMemoryException20160630.txt (21.8 KB)

Hi Dennis,

If you have to choose the multiply tile mode, please make the layers with same size if possible. The best way is keep 256x256 by default. I am not sure whether set different tile size will cause this issue, but I remembered we ever met an issue which is related with different tile size, maybe here have a unknown problem.

Thanks for provide us the outofmemory exception message, but this exception maybe not related with the line where it thrown, for example, here it thrown by the MemoryStream.ToArray, but maybe other lines make the memory not enough.

But I think it still be helpful to think about the issues.

Regards,

Don

hi Don,

I’ve attached another log with the ‘collection modified’ exception. These series of exceptions actually occurred on an InMemoryFeatureLayer. These layers do not have the Styles changed, they are constant. So I’m thinking that maybe changing styles is not the cause of this issue. Unfortunately I did not have the full logging enabled for this series, but will attempt to capture in the future.

Changing TileSize to 256x256 results in much slower drawing speeds as well as the labeling of street names ends up putting a label for just about every feature, which clutters the display. Also at this TileSize labels get truncated when they cross Tile boundaries.

I’ve found that setting a TileSize of 1680x1050 with SingleTile results in the fastest draw time. Setting the MrSid TileSize to 1680x1050 with MultipleTile appears to work best in terms of drawing speed. With these settings going to a new extent while maintaining ZoomLevel results in draw times of roughly two seconds. Zoom In/Out is also more responsive with these configurations.

Unfortunately these exceptions only occur in a production environment. I am thinking about possibly writing some code that could simulate real-time use and then hopefully recreate these exceptions.

Do yo have any suggestions or have you discovered anything?

Thanks,
Dennis

CollectionWasModifiedInMemoryFeatureLayer.txt (2.1 KB)

Hi Dennis,

Thanks for your further information.

I am sorry we hadn’t get any news about this issue. If you choose single tile mode for 1680x1050, I think that can avoid many exceptions, but if you choose 1680x1050 with multipleTile, maybe it looks faster, but I think that will takes much more source, because the tile cut won’t be suitable the current extent, so it will draw more area out of current extent background.

And if you use 256x256 then met the labeling cut, I think adjust the label style can solve most of the problem for it. But if that’s slower, choose single tile mode should be better. For the MrSid, in fact multiply tile mode won’t get faster, because we call the API with 3rd part dll.

Regards,

Don