Wednesday, March 22, 2017

Catch Exception - Attempted to read or write protected memory in ESRI ArcObjects .Net 4.0 Framework

1 Comment
First - Don't write the code to throw "Attempted to read or write protected memory" ..it is bad.

Second - If you are working on legacy codes and COM objects that throws "Attempted to read or write protected memory" while writing ArcMap add-ins, catch exceptions to prevent application crash, in my case ArcMap.


Step #1 - Add following snippet to config file - app.config for Arc-addin

<configuration>
   <runtime>
      <legacyCorruptedStateExceptionsPolicy enabled="true" />
   </runtime>
</configuration>
Step #2

Add -

[HandleProcessCorruptedStateExceptions] 
[SecurityCritical]
on the top of function you are tying catch the exception

[HandleProcessCorruptedStateExceptions]
[SecurityCritical]
public IFeatureLayer GetOrCreateFeatureLayer(string path, esriGeometryType type, ISpatialReference sr)
{
//body
}

Thursday, March 16, 2017

Good compatibility of latest vagrant and virtual box

Be The First To Comment
Continuing from my older post  on Vagrant 1.7.2 / 1.9.2 and Virtualbox 4.3.12  / 5.1.14. I upgraded into Vagrant 1.9.2 and 5.0.x and 5.1.x , because of security vulnerabilities on those Virtualbox versions, but my shell provisions and puppet provision that used to work on old setting suddenly stopped working and tried various workaround to make them working but failed until Virtualbox 5.1.18. I use chocolaty, to upgrade/install vagrant and virtual box in Windows 7 host and able to fire 'vagrant up' to provision my new guest.

Step 1

Install chocolaty in host machine using cmd.exe (Run elevated)
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
      choco -v (Just to make sure chocolaty installed correctly)
      
      0.10.3 (as of 3/16/2017)

    Step 2
    Open Windows' power shell (Run elevated) 
    1. Install or upgrade oracle virtual box

    choco install virtualbox -version 5.1.18
                                                                                                             5.1.18 r114002
    choco upgrade virtualbox

    2. Install or upgrade vagrant

    choco install vagrant -version 1.9.2

    choco upgrade vagrant

    3. Restart the machine
    4. Vagrant up ....Boom all old scripts starting work again!
     

    © 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

    About Me