ThinkGeo.com    |     Documentation    |     Premium Support

Various multiple postback issues

I am seeing the following behaviour with my map:


1. (n items remaining); n gets higher and higher with multiple postbacks - never gets to zero


2. Occasionally: 'Cannot access file when it is closed' message (or similar) exception in FeatureSource_CustomColumnFetch method


3. Occasionally: text on the map to do with collection data. (Afraid I didn't write down the messge. It's  become awfully slow. I'll update this post if I manage to reproduce it)


4. Occassionally: error text on the map, follled by break in server code: 'A first chance exception of type 'System.InvalidOperationException' occurred in MapSuiteCore.DLL Additional information: The FeatureSource is not open.   Please call the Open method before calling this method.' inside FeatureSource_CustomColumnFetchmethod

I think it's all down to multiple postbacks; whereby postbacks are ocurring while the map is still trying to render itself. I'm guessing that things get closed in the wrong order and it gets it knickers in a twist.


What's the recommended approach?


In my postbacks I need to:


1. (Mostly) change the size of the map


2. (Occasionally) completey change the data and feature layers


cheers


Matt




Matthew, 
  
 Thanks very much for letting us know those problems you met!  
  
 The first issue exists in former versions and has been solved in the current version (3.1.16), please get the latest one and have another try. 
 The second issue does occur occasionally and we’ll try to fix it in the future. 
 I couldn’t recreate the other 2 issues.  Could you please provide your test demo, which will be very helpful for us to recreate? 
  
 Thanks, 
  
 Ben 


Ben,


I tend to disagree with your answer regarding the first issue Matthew mentioned. I have version 3.1.16. I also manage multiple postbacks and get the n items remaining which never gets down to 0.


Related to this: I have a plain vanilla GridView inside a tabbed panel. Map in an UpdatePanel. I capture the "SelectedIndexChanged" event when the user selects a row in the grid. Based on this row, I update certain features on the map (dynamicoverlay). However, the map never updates, even though I issue Map1.DynamicOverlay.ReDraw(). If I pan/zoom the map, the changed feature shows the change applied.


Chris



Chris, 


There used to be a problem that one request blocks our whole tiles. We have solved it in the current version and we didn’t meet the similar issues from then. As there are many possibilities which may block the requests, I recommend you to check it with some monitor tools, such as HttpWatch, to find out which address blocks the queue. Also could you send us your sample so we can check here if it is caused by some bugs within the map control?
 
We made a demo for your second problem. Please have a look what’s the codes difference between this and yours.
 
Thanks,
 
Ben

455-Post5347.zip (8.34 KB)

I have just upgraded to 3.1.24 and still map rendering is unreliable. Sometimes it works, sometimes it doesn't. 

For example 







I get the following exception in the Layer_CustomColumnFetch method. Note that it has already rendered part of the map: 

System.InvalidOperationException occurred 

Message="The FeatureSource is not open. Please call the Open method before calling this method." 

Source="MapSuiteCore" 

StackTrace: 

at ThinkGeo.MapSuite.Core.x6d719af406ea4c2c.x1026dfc371fdceea(Boolean x40fc51452dedaf8a) 

at ThinkGeo.MapSuite.Core.FeatureSource.GetFeatureById(String id, IEnumerable`1 returningColumnNames) 

at Emb.Msmo.WebSite.UserControls.Charts.ResultsMap.KpiGroupLayer_CustomColumnFetch(Object sender, CustomColumnFetchEventArgs e) in D:\Projects\msmo-trunk\msmo\Source\Emb.Msmo.WebSite\UserControls\Charts\ResultsMap.ascx.cs:line 60 

InnerException: 



Even when I change my code to the following it still fails: 

FeatureLayer kpiGroupLayer; 

FeatureSource source = null; 

Feature feature; 

try 



kpiGroupLayer = (FeatureLayer)Map1.StaticOverlay.Layers["kpiGroupLayer"]; 

source = kpiGroupLayer.FeatureSource; 

source.Open(); 

feature = source.GetFeatureById(e.Id, this.kpiFeatureColumn); 

string geography = feature.ColumnValues[Columnkey]; 















It consequently only shows part of the map (one image square) ,and the n items remaning is stuck at two. 









Sometimes on the map it displays 'the record is invalid, please call the Validate method to check the failed reason. Record Index: 97' 



- Why doesn't it include the reason in the exception information? 

- The Validate() method doesn't seem to exist. How do I get at it (in the code above)? 









Sometimes on the map it displays the text 'Object reference not set to instance of an object'. 



System.NullReferenceException was caught 

Message="Object reference not set to an instance of an object." 

Source="MapSuiteCore" 

StackTrace: 

at ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.x0bb99de02aec07fa(x6193df574f38e922 xb55aa7011f50124f) 

at ThinkGeo.MapSuite.Core.ShapeFileFeatureSource.OpenCore() 

at ThinkGeo.MapSuite.Core.FeatureSource.Open() 

at Emb.Msmo.WebSite.UserControls.Charts.ResultsMap.KpiGroupLayer_CustomColumnFetch(Object sender, CustomColumnFetchEventArgs e) in D:\Projects\msmo-trunk\msmo\Source\Emb.Msmo.WebSite\UserControls\Charts\ResultsMap.ascx.cs:line 64 

InnerException: 





just 



HELP! It looks rubbish. Not something we can give to users. See:



 



Mattew, 
  
 From your description, I guess there are two possibilities to cause your issue; one is the custom data source where you fetched from while another one is multi-thread. 
  
 Now, we can exclude the possibilities of your issue one by one.  
  
 First of all, this issue happens when working with CustomColumnFetch event; if the custom data is loaded from a database of another machine, please try to change the data server to your local machine. If it’s local already, please change it to loading from ShapeFile; or remove the event directly to see if the issue still exists. 
  
 At the meantime, I’ll add a temporary property to disable the multithread; but it may be removed in our upcoming public release. 
  
 We’ll send this temporary version to you soon. Hope it works. 
  
 If you have any questions please let me know. 
  
 Thanks, 
 Howard

I’m not sure what you mean by 'custom data '. 
  
 In the OnPreRender method of the .ascx the data is read from a database, or from a cache, but is then stored in a member variable of the control: 
    private Dictionary<string, double> geoData; 
 The feature layer is loaded from a file 
    ShapeFileFeatureLayer kpiGroupLayer = new ShapeFileFeatureLayer(this.shapeFilePath); 
 … 
    kpiGroupLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(KpiGroupLayer_CustomColumnFetch); 
    Map1.StaticOverlay.Layers.Add(“kpiGroupLayer”, kpiGroupLayer); 
  
 If I comment out the attachment of the KpiGroupLayer_CustomColumnFetch I get ‘Input string was not in a correct  format’ displayed on the map.

Matthew, 
  
 "Custom Data" means the data from a database or a cache which you are fetched in the event. 
  
 When you get the new temporary version, Please set the IsMultiThreadDisabled to true on the LayerOverlay, and see if the issue still exists. 
  
 Or loading the data from a shape file locally to see if the issue still exists. 
  
 These two options may helps you to find whether your issue is caused by multi-thread or loading from database. 
  
 If you have any questions please let me know. 
  
 Thanks, 
 Howard

Hi, Got your control - thanks. 

My findings: It is still unreliable. 

1. My layer adding code is now: 

Map1.StaticOverlay.Layers.Add("kpiGroupLayer", kpiGroupLayer); 

Map1.StaticOverlay.IsMultiThreadDisabled = true; 



2. My _Custom ColumnFetch is now 

kpiGroupLayer = (FeatureLayer)Map1.StaticOverlay.Layers["kpiGroupLayer"]; 

source = kpiGroupLayer.FeatureSource; 

source.Open(); 

feature = source.GetFeatureById(e.Id, this.kpiFeatureColumn); 

(for months I was working without the .Open method, but it seems to be necessary since 3.1.124 



3. But it doesn't work. 

I get the following exception 

System.Collections.Generic.KeyNotFoundException occurred 

Message="The given key was not present in the dictionary." 

Source="mscorlib" 

StackTrace: 

at System.ThrowHelper.ThrowKeyNotFoundException() 

at System.Collections.Generic.Dictionary`2.get_Item(TKey key) 

at ThinkGeo.MapSuite.Core.GeoCollection`1.get_Item(String key) 

at ..._CustomColumnFetch(Object sender, CustomColumnFetchEventArgs e) 



at the line kpiGroupLayer = (FeatureLayer)Map1.StaticOverlay.Layers["kpiGroupLayer"]; 



It turns out that Map1.StaticOverlay.Layers.COunt is zero. 



The user sees the image attached. 






If I press the zoom in button and wait a long time (~ 8 seconds) the map does draw correctly, but obviously that's not really acceptable.



Matthew, 
  
 I have some questions for you, 
 1, if you remove the CustomColumnFetch event, does your application work fine? 
 2, I see there is an exception in the screenshot about “collection was modified enumeration operation may not execute.”. Is there any logic in the event? 
 3, I’m not sure why the layers count is zero, could you please provide us a sample we can easily recreate your issue? 
 4, does the issue happens in IIS or debug mode or both? 
 5, please provide us your environment such as OS, X86 or X64, IIS version, etc. 
  
 If you have any questions please let me know. 
  
 Thanks, 
 Howard

1, if you remove the CustomColumnFetch event, does your application work fine? 

A. After I comment out the add of the event the map says 'Input string was not in a correct format.'. There is no indication anywhere I can find (e.g. the event log which says which input is wrong, what the incorrect value is, nor why it is wrong). The data looks fine to me but there about 3,000 values so I might have missed one.




2, I see there is an exception in the screenshot about "collection was modified enumeration operation may not execute.". Is there any logic in the event? 

A. Do you mean the ..._CustomColumnFetch event? What do you mean by 'logic'? The core of the code is this:

                FeatureLayer kpiGroupLayer;

                FeatureSource source = null;

                Feature feature;

                try

                {

                    kpiGroupLayer = (FeatureLayer)Map1.StaticOverlay.Layers["kpiGroupLayer"];

                    source = kpiGroupLayer.FeatureSource;

                    source.Open();

                    feature = source.GetFeatureById(e.Id, this.kpiFeatureColumn);

                    string geography = feature.ColumnValues[Columnkey];

                    if (this.geoData.ContainsKey(geography))

                    {

                        double value = geoData[geography];

                        e.ColumnValue = value.ToString(CultureInfo.InvariantCulture);

                    }

                    else

                    {

                        e.ColumnValue = "0";

                    }

                }




3, I'm not sure why the layers count is zero, could you please provide us a sample we can easily recreate your issue? 

A. The layers count is only zero sometimes. I can't provide you a sample since the application is pretty large. When I create stand-along test web pages with essentially the same code in it works OK.



4, does the issue happens in IIS or debug mode or both? 

A. Visual Studio .Net 2008 (9.0.30729.1) built-in debug server


5, please provide us your environment such as OS, X86 or X64, IIS version, etc. 

A. Windows XP SP3. 32 bit.



Hello, is there anybody there?

Matthew, 
  
 Sorry for the delay!  
  
 It seems there are bunch of problems hidden in your App. I just want to make sure a few things related the data you used. 
  
 1) How many layers are you trying to use? I suppose it should be ONLY 1, which is kpiGroupLayer (a ShapeFileFeatureLayer). Right? 
 2) I am not very sure why you want to use CustomColumnFetch event to fetch some data still from the same ShapeFileLayer FeatureSource. This event is supposed to supply some data does not exist in the same featurelayer featureSource. I did not find any clues you use another source to provide the data. 
  
 Can you explain a bit why you want to use this event to fetch data still from the same source? 
  
 3) Can you provide your using shape file data if possible, because at the very beginning it is said some of you data are not valid, I just want to make sure this is a valid data before we are going further. 
  
 Any more problems just let us know. 
  
 Thanks. 
  
 Yale 


Hi Yale, 



Thanks for replying. 



1). I add a number of ShapeFileFeatureLayers according to what options a user has set. There is one for the postcode areas, one for towns, and one for postcode area centres. Is this wrong? Surely the map would throw an exception if I were not allowed more.


The two postcode-related areas come from the same file on disk, The towns layer comes from another file on disk. ZoomLevels are set that at the widest extent (seeing the whole country) onthe the first layer is visible.


I add the layer like this: 

   Map1.StaticOverlay.Layers.Add("kpiGroupLayer", kpiGroupLayer); 

But even with one shape file it does not work. If I comment-out adding of the other layers it fails with 'Input string was not in a correct format' (that is, it draws that text on the map). Is it too much to ask for it to report which input string. what value, and what format is expected? Why does it hide this information?


2) I am not trying to fetch data from the same source. What I want to do is colour-code the regions on the map (from the shape file on disk) with data from the database. That is, the shape file has a column called 'COM_DIST' (for example), and I want to look up the value for which that should be colour-coded from a Dictionary which I have populated from the database. Therefore the reason I am looking into the source is to find the key value for the aforementioned dictionary given the id passed to me by the ..._CustomColumnFetch event. 



3) If you mean the shape file - we have purchased this and I cannot upload it to this forum. I have uploaded up to a ShapeFile folder I have created on the FTP site you gave me access to.


I can load it into Map Suite Explorer with no problems reported. If I turn on the (i) feature and click on regions sometimes I get data back, but sometimes I get: 

   System.ArgumentOutOfRangeException 

   The decimal degree longitude value you provided was out of range. 

   Parameter name: fromLongitude 

But does it say what the erroneous value was? No. Does it say what the range of valid values is? No. Does it report detailed info to the Windows  event log? No.


Why haven't your developers taken the extra 30 seconds to augment the error with this kind of information. For  example, this is what Sql Server reports if you try and create a row that's too big: 

   Creating or altering table 'T' failed because the minimum row size would be 16011, including 7 bytes of internal overhead. This exceeds the maximum allowable table row size of 8060 bytes. 

I'm sure it would save a lot of time in the long run.


Anyway, thanks for your help

cheers 



Matt 

 



Matthew,


I did not get the data from our support up to now.
1) About the exception happened in the MapSuiteExplorer.
    System.ArgumentOutOfRangeException 

   The decimal degree longitude value you provided was out of range. 

   Parameter name: fromLongitude
 
This exception will happen if you mouse click into a Point which is outside the world extent, because some calculation is based on the Longitude and Latitude, if the longitude and latitude is outside the reasonable range, it will cause some unexpected problems.
 
2) Attachment contains a demo which I showed a basic and easiest way to use the CustomDataFetch event to get some data which was not existing in the shape file for rendering the label.
 
Besides, Can you paste the code in your App for this event, and I will test to see if this problem will recreate after I get the data.
 
Sorry for the inconvenience now, any more questions just let me know.
 
Thanks.
 
Yale

828-WebPost5347Demo.zip (182 KB)

Sorry, you have lost me. Does your 1) refer to my number 3). I assume it does. 
  
 Your ref 1., my ref 3. ArgumentOutOfRangeException: I have not been so stupid as to click outside the map. Clicking a few pixels different very much within the map causes the exception. But, I do not care about MapSuiteExplorer. What I care about it that I cannot get, after 6 months of work, a map to display reliably. 
  
 Your ref 2., my ref  1. THE MAP DOES NOT WORK EVEN WITH THE CUSTOMCOLUMN FETCH EVENT SUBSCRIPTION COMMENTED OUT. I repeat. On initial rendering you get the screen shot above. 
  
 I can not post my code to this forum. I would upload it to the FTP site, but FTP access now seems to not work. However, you can see the essential code in the post of 06-19-2009 04:35 AM above.  
  
 I do not understand why you sent me a dynamic layers example. What has that got to do with the problem? 
  
 You asked me to send the map data, so I did. What is your comment upon it?

Matthew,  
  
 If you would like please contact support at the number listed at the bottom of this page so that we might verify your FTP access information. 


Matthew, 
  
 Sorry for lasting this issue for a long time. I’ve told our support man to respond you, and we need to verify your FTP information. I think the best way is to send us your code and shape files because we can’t recreate the isusse through the code slice. 
  
 “Input string was not in a correct format” is a system exception; I think there may be some culture or data convertion issue in our product or may be in you application. We’ll check it out as soon as we get the completed code and data. 
  
 Or I have an idea which you can work around. Create a new shape file which has the origin shape information and the data from two shape files you need. It’s just an idea and you’ll have higher performance in this way. 
  
 Just let me know if you have more questions. 
  
 Thanks, 
 Howard

Hi all, some progress… 
  
 It turns out that the ArgumentOutOfRangeException was caused simply because I had commented out the wiring up of the CustomColumnFetch event (as I was advised earlier in this forum thread), and the class break column name I had given was the name of a real column, with textual values in it. Putting back the CustomColumnFetch event and changing the text in the ClassBreakStyle means that I can now (sometimes) get a map. 
  
 I say sometimes, because I am effectively back to where I was in the post of ‘06-16-2009 11:14 AM’. But let’s deal with one point at a time. 
  
 In the CustomColumnFetch event (see code above) the following line: 
    kpiGroupLayer = (FeatureLayer)Map1.StaticOverlay.Layers[“kpiGroupLayer”]; 
 sometimes fails with  
    System.Collections.Generic.KeyNotFoundException occurred, Message=“The given key was not present in the dictionary.” 
  
 I say sometimes but I really mean often. Perhaps 100 times in the rendering of one map. 
  
 In the debugger at this poine I see there is another thread stopped inside my map control - in the OnPreRender, and in fact just where it is initializing the static overlay. This seems to be zapping the collection for the map control. What I suspect is happening is this: 
  
 0. (The state of the application changes such that the .ascx is loaded an starts to draw a map. The map is initialized OK, the CustomColumnFetch event is set up. This is inside an AJAX UpdatePanel). 
  
 1. The browser starts to render the tiles and makes fetches for the .axds. The CustomColumnFetch event starts firing and data is returned. This seems to work OK for some time (one or two tiles). 
  
 2. (For whatever reason), the (an) AJAX UpdatePanel is making another request for the page. The OnPrerender event of the .ascx containing the map is being called, and the map is being re-set up. The static overlay is being assigned, … 
  
 3. An .axd fetch comes in and lo! the static overlay is empty - bang! 
  
 This explains some of the wierd random behaviour - according to when/how the two threads try and access the overlay different error conditions could occur - e.g. the above, or other occasion swhen it says the collection has been modified, or the overlay closed. 
  
 So the question is - how do we prevent this error occuring? These are genuinely different threads. Thread local storage is separate (as I can see if I set a kind of semaphore in the object - it is completely independent in the different threads). But the overlay seems to be common between them. How is this so? How can I make them not interfere? 
  
 cheers 
  
 Matt

Matthew, 
  
 I think it may be the reason. Could you provide us the axd address caused this issue. Also we are looking forward your sample. 
  
 Thanks, 
 Howard