ThinkGeo.com    |     Documentation    |     Premium Support

AcessViolationException on Invoke

When I upgraded from the trial to full version of MapSuite Desktop version 3.1.299, I started getting AcessViolationException exceptions when I call _Map.Invoke when _Map.InvokeRequired is true.  This happens for both builds in Debug and Release mode.  When I run my application in the debugger, it runs fine and has no problem (both Debug and Release compiles).


Here are the stats on the two key DLLs that I am using:



        
  • DesktopEdition.dll, 276,480 bytes, modified Nov 16, 2009 at 12:57:56PM, file version 3.1.299.0

  •     
  • MapSuiteCore.dll, 1,655,808 bytes, modified Nov 16, 2009 at 12:57:28PM, file version 3.1.299.0


Note that I changed no code.  I also noticed this happended on some sample projects.  Specifically, the TestGenerateTilingImages sample, though not for an Invoke call.


Has anyone else seen this?  My .ZIP file seemed fine, so I'm not sure what the deal is here.  I could refactor my code to not use Invoke calls, since they are kind of inefficient, but my concern is that I have an issue that will show up elsewhere.



Brain, 
  
 Thanks for your post. 
  
 I am sure you are now using our last public release version of Destkop 3.1.299.0. 
  
 So what you are just change is from Trial version DLLs to Full version DLLs? They should be exactly the same behavior. Are you using the Multi-threaded mode in your application?  
  
 Could you send us a small sample applicatioin to show us your problem? Because it really wired that this only happens in Full version. 
  
 Any more information would be appriciated. 
  
 Thanks. 
  
 Yale 


I did quite a bit more experimenting and refactoring, and the problem remains.  I narrowed it down to one file, MapSuiteCore.dll.


If I use the Trial version of MapSuiteCore.dll, then everything is fine.  If I switch to the full version, which is 1,655,808 bytes compared to the trial which is 1,656,832 bytes, then I get the exception very repeatedly.


I can use all other files from the full version with the trial MapSuiteCore.dll, and it works.  Those files from the full version include MapSuiteCore.xml, DesktopEdition.dll, DesktopEdition.xml, GeoAPI.dll, and NetTopologySuite.dll.


Sorry, I have not had time yet to build the sample solution to illustrate this.  Have you had any more luck?  Can you email me an updated MapSuiteCore.dll?  Thanks.



Brian, 
  
 Thank you for more information, we focus the MapSuiteCore.dll, but still can not recreate this exception. 
  
 In order to find what problem is, I am afraid we need more information from you. That will be great helpful. 
 Have you set any values to properties of winformsMap? Or just keep the default value, if you did, please provide a list of them,  
  
 And I have done some research about AccessViolationException, it is thrown when there is an attempt to read or write protected memory. It occurs only when verifiable managed code interacts with unmanaged code or with unsafe managed code.  
  
 The entire code of MapSuite is managed code, but we still use few unmanaged code, such as MapSuiteEcw, MapSuiteMrSid, MapSuiteRaster, MapSuiteFdo and MapSuiteProjection. Could you verify these DLLs? If your OS is x86, they should be in C:\Windows\System32, if your OS is x64, they should be in C:\Windows\SysWOW64. if they’re not right, you can download the DesktopEditionFull3.1.299DllPackage.zip, and extract related files to override them. 
  
 This is very strange issue which we never encounter before, hope we have luck to solve it, and then we will provide an updated DLL to you. 
  
 Thanks 
 James 


I should note that this happens on  both Windows7 x64 and Windows XPSP2 x64.


I made sure that the files in C:\Windows\SysWOW64 matched all those in [MapSuite]\Developer Reference\System32.  The only differences were the locked files msvcp71.dll and msvcr71.dll, which were older in XPSP2, but I could not change them.  For good measure, I coped the MapSuiteFdoExtensionx64 to C:\Windows\SysWOW64\MapSuiteFdoExtensionx64, though I am not using it.


The interesting thing is that this happens on a both XP and 7 64-bit.  On both, I had installed the desktop trial edition first, then uninstalled it, then installed the full version.


The exception still occurs on the same line in both operating systems.  I have 100% managed code in my application, so it seems unlikely that I'm causing the memory to be corrupt.  I also have lock () statements around my relevant code blocks to make things thread-safe.  Time is short, but I hope to replicate this in a small solution sometime, but though to give you an update...



Brian, 
  
 Thanks for your more information, but unfortunately we still can not recreate the exception. 
  
 I have tested both Windows7 x64 and Windows XPSP2 x64, first installed the DesktopEditionEvaluation3.1.299 package, and then uninstalled it, then installed the DesktopEditionFull3.1.299, I run our HowDoI sample directly or run the solution. Not any exceptions thrown. 
  
 The investigation is still going on, we didn’t give up but for now there is no clue to solve the problem because nobody encounters this problem before. 
  
 If you can provide a sample to show us your problem, it will be great helpful. 
  
 I am afraid we can not fix your problem so far. Sorry for the inconvenience. If you have any insights about it that might help us, please let us know.   
  
 Thanks 
  
 James 


Thank you for your efforts to date.  As you can imagine, this is frustrating to me too – especially since it has happened on two different machines and operating systems. 
  
 I am working to create a sample that has the same problem, but have not succeeded yet.  I will pass it on when I get it to fail the same way.

Brian, 
  
 If I have made any progress I will let you know. 
  
 Thanks for your patience.  
  
 James 


I think I may have found the 'answer'. On a machine where I never installed the trial version, the exception does not happen. 



To 'fix' a machine where I did, you need to remove the Program Files\ThinkGeo\Map Suite Desktop folder manually after uninstall, leaving only the Map Suite Desktop Full Edition 3.0 folder. Everything else stayed the same, i.e. same full release files in System32 and SysWOW64. 



I am not absolutely certain this is the 'solution' but the problem went away on one machine.  On another, where I tried the same thing, the problem persisted...  SIGH.  Will keep you informed.


The good news is that if I try to run my software on a machine that has had neither the trial or full version installed, it does not happen.  In other words, I Xcopy the full version DLLs to it and it works fine.



Brian, 
  
 Thanks for your more information, we will keep on researching this issue, if we find any useful thing I will let you know. 
  
 It’s right that if you xcopy the full DLLs to the clean machine and it works fine. The full license ensures that you application works at runtime, but not for debugging.  
 You can image that you will deploy your application with MapSuite DLLs to your customers’ machines, they don’t know who is ThinkGeo, they couldn’t install MapSuite package, but they know they can run your application that don’t care which DLLs it refers. But they can not debug the dll, for example, they create a new project and refer the MapSuiteCore.DLL, and if they use F5 it can not work will return the blank screen, if they use Ctrl+F5 without debugging it can work fine. 
  
 Please let me know if you have more comments. 
  
 James