Application to 64 Bit from 32 bit

stevebegi

New member
Joined
Jun 3, 2020
Messages
4
Programming Experience
Beginner
I have an ArcMap application (in Visual Studio) that has only been used in a 32bit environment. When I took the file and added the application to my ArcMap software on the 64bit environment I get an error about 80% through the process. I noticed that the project in the configuration manager was set to x86. I changed to ANY CPU and recompiled. Still get error on 64 bit environment. I am still recompilling project in my 32 bit environment. Do I need to recompile project/application in my new 64 bit environment? Thanks for any assistance. Below is the code that gets the error, it goes to my catch exception error message "Error setting symbols"

FixMarker:
Sub FixMarkers(aLists(,) As Object)
    Dim pDoc As IMxDocument

    pDoc = application.Document

    Dim pMap As IMap

    pMap = pDoc.FocusMap

    Dim pSymbol As IMarkerSymbol
    Dim pLyr As IGeoFeatureLayer

    pLyr = pMap.Layer(0)

    Dim pRenderer As IUniqueValueRenderer

    pRenderer = New UniqueValueRenderer

    ' single field to base the symbology on
    pRenderer.FieldCount = 1
    pRenderer.Field(0) = "List"

    iLists = aLists.GetUpperBound(0)

    Try
        For x = 1 To iLists
            System.Windows.Forms.Application.DoEvents()
            WriteToLog("SymbologyMarker: " + x.ToString())
            pSymbol = SymbologyMarker((aLists(x, 2)), CShort(aLists(x, 3)))
            pRenderer.AddValue(aLists(x, 1), "", pSymbol)
        Next x

        pLyr.Renderer = pRenderer
        pDoc.UpdateContents()
        pDoc.ActiveView.Refresh()
    Catch exc As Exception
        Dim result1 As DialogResult = MessageBox.Show("Should the program continue? An Error occured: " & "Error setting symbols: " & exc.Message,
                                                      "Error: Continue?",
                                                      MessageBoxButtons.YesNo)
        If result1 = DialogResult.No Then ExitApp()
    Finally
        WriteToLog("Done with symbols: " & Now)
    End Try
End Sub
 
Last edited by a moderator:
Depending on your version of VS, setting the Target Platform to Any CPU may still have a box checked that says Prefer 32-bit. That means that your app can run in a 64-bit process on systems that don't support 32-bit but will still run in a 32-bit process if it can. x86, on the other hand, will only run in a 32-bit process and so won't run on systems that don't support 32-bit. If you want your app to run in a 64-bit process whenever it can then you need to uncheck that box. That way, your app will be 64-bit if possible but will still run on 32-bit systems. If you select x64 then it will only run on 64-bit systems and only in a 64-bit process. In summary:

x86 = always 32-bit and only on systems that support 32-bit processes
Any CPU, Prefer 32-bit checked = 32-bit if possible and 64-bit on systems that don't support 32-bit processes
Any CPU, Prefer 32-bit unchecked = 64-bit if possible and 32-bit on systems that don't support 64-bit processes
x64 = always 64-bit and only on systems that support 64-bit processes
 
On an unrelated note, you could undoubtedly write more succinct code than that. There are likely other improvements to be made too but here's how I might write similar code:
VB.NET:
Sub FixMarkers(aLists(,) As Object)
    Dim pDoc As IMxDocument = application.Document
    Dim pMap As IMap = pDoc.FocusMap
    Dim pSymbol As IMarkerSymbol
    Dim pLyr As IGeoFeatureLayer = pMap.Layer(0)
    Dim pRenderer As IUniqueValueRenderer = New UniqueValueRenderer

    ' single field to base the symbology on
    pRenderer.FieldCount = 1
    pRenderer.Field(0) = "List"

    iLists = aLists.GetUpperBound(0)

    Try
        For x = 1 To iLists
            System.Windows.Forms.Application.DoEvents()
            WriteToLog("SymbologyMarker: " & x)
            pSymbol = SymbologyMarker(aLists(x, 2), CShort(aLists(x, 3)))
            pRenderer.AddValue(aLists(x, 1), "", pSymbol)
        Next x

        pLyr.Renderer = pRenderer
        pDoc.UpdateContents()
        pDoc.ActiveView.Refresh()
    Catch exc As Exception
        If MessageBox.Show("Should the program continue? An Error occured: Error setting symbols: " & exc.Message,
                           "Error: Continue?",
                           MessageBoxButtons.YesNo) = DialogResult.No Then
            ExitApp()
        End If
    Finally
        WriteToLog("Done with symbols: " & Now)
    End Try
End Sub
 
Thank you.

Unfortunately the prefer checkbox is greyed out on my version.

I have tried setting the target cpu to x64, but when I do this the application wont even run at all.

Would the .NET framework make a difference?

Thank you
 
Unfortunately the prefer checkbox is greyed out on my version.
This check box is available only if all of the following conditions are true:

  • On the Compile Page, the Target CPU list is set to Any CPU.
  • On the Application Page, the Application type list specifies that the project is an application.
  • On the Application Page, the Target framework list specifies the .NET Framework 4.5.
(.Net 4.5 or higher)
 

Latest posts

Back
Top