Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. etting Access Violation Exception -Attempted to read or write protected memory - when trying to convert unmanaged array of structures into managed class in Vb.Net (VS2010,4.0 framework) in Windows 7 -64 bit mode.

etting Access Violation Exception -Attempted to read or write protected memory - when trying to convert unmanaged array of structures into managed class in Vb.Net (VS2010,4.0 framework) in Windows 7 -64 bit mode.

Scheduled Pinned Locked Moved Managed C++/CLI
csharpdata-structuresjsonperformance
6 Posts 4 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VijaySandur
    wrote on last edited by
    #1

    Getting Access Violation Exception when trying to convert unmanaged array of structures into managed in Vb.Net(VS2010,4.0 framework) in Windows 7 -64 bit mode. Sample Source Code _ Public Class vb_menu_dotnet Public level As Short Public menu_id As String Public short_desc As String Public parent_id As String Public access As Short Public flag As Short Public menu_desc As String End Class Dim current As IntPtr Dim outArray As IntPtr Dim manArray(100) As vb_menu_dotnet vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call current = outArray Dim j As Integer For j = 1 To 100 manArray(j) = New vb_menu_dotnet() Marshal.PtrToStructure(current, manArray(j)) //Access Violation Exception

    Vijay

    J L T 3 Replies Last reply
    0
    • V VijaySandur

      Getting Access Violation Exception when trying to convert unmanaged array of structures into managed in Vb.Net(VS2010,4.0 framework) in Windows 7 -64 bit mode. Sample Source Code _ Public Class vb_menu_dotnet Public level As Short Public menu_id As String Public short_desc As String Public parent_id As String Public access As Short Public flag As Short Public menu_desc As String End Class Dim current As IntPtr Dim outArray As IntPtr Dim manArray(100) As vb_menu_dotnet vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call current = outArray Dim j As Integer For j = 1 To 100 manArray(j) = New vb_menu_dotnet() Marshal.PtrToStructure(current, manArray(j)) //Access Violation Exception

      Vijay

      J Offline
      J Offline
      John Schroedl
      wrote on last edited by
      #2

      You may need to try a VB.NET forum. This is for C++/CLI code.

      1 Reply Last reply
      0
      • V VijaySandur

        Getting Access Violation Exception when trying to convert unmanaged array of structures into managed in Vb.Net(VS2010,4.0 framework) in Windows 7 -64 bit mode. Sample Source Code _ Public Class vb_menu_dotnet Public level As Short Public menu_id As String Public short_desc As String Public parent_id As String Public access As Short Public flag As Short Public menu_desc As String End Class Dim current As IntPtr Dim outArray As IntPtr Dim manArray(100) As vb_menu_dotnet vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call current = outArray Dim j As Integer For j = 1 To 100 manArray(j) = New vb_menu_dotnet() Marshal.PtrToStructure(current, manArray(j)) //Access Violation Exception

        Vijay

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Dim current As IntPtr
        Dim outArray As IntPtr
        Dim manArray(100) As vb_menu_dotnet

        vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call

        You have not initialised any of the pointers that you are sending to the C-language library. Take a look at this P/Invoke tutorial[^] for more information.

        Use the best guess

        T 1 Reply Last reply
        0
        • L Lost User

          Dim current As IntPtr
          Dim outArray As IntPtr
          Dim manArray(100) As vb_menu_dotnet

          vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call

          You have not initialised any of the pointers that you are sending to the C-language library. Take a look at this P/Invoke tutorial[^] for more information.

          Use the best guess

          T Offline
          T Offline
          Tripurari Chaudhary
          wrote on last edited by
          #4

          Hi , whatever database u r acessing or data retrieval policy u might be using for e.g INI file,must be in Read Mode,Try to make it Write protected

          L 1 Reply Last reply
          0
          • V VijaySandur

            Getting Access Violation Exception when trying to convert unmanaged array of structures into managed in Vb.Net(VS2010,4.0 framework) in Windows 7 -64 bit mode. Sample Source Code _ Public Class vb_menu_dotnet Public level As Short Public menu_id As String Public short_desc As String Public parent_id As String Public access As Short Public flag As Short Public menu_desc As String End Class Dim current As IntPtr Dim outArray As IntPtr Dim manArray(100) As vb_menu_dotnet vb_dotnet_get_menu_hierarchy(p_menu_handle, p_apl_id, outArray) //C API call current = outArray Dim j As Integer For j = 1 To 100 manArray(j) = New vb_menu_dotnet() Marshal.PtrToStructure(current, manArray(j)) //Access Violation Exception

            Vijay

            T Offline
            T Offline
            Tripurari Chaudhary
            wrote on last edited by
            #5

            Hi ,
            whatever database u r acessing or data retrieval policy u might be using for e.g INI file,must be in Read Mode,Try to make it Write protected

            1 Reply Last reply
            0
            • T Tripurari Chaudhary

              Hi , whatever database u r acessing or data retrieval policy u might be using for e.g INI file,must be in Read Mode,Try to make it Write protected

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Did you actually read the OP's question?

              Use the best guess

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups