Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:25:05+00:00 2026-06-11T14:25:05+00:00

I have a C DLL I wrote to create rasterized graphics which I want

  • 0

I have a C DLL I wrote to create rasterized graphics which I want to use in VB.NET. At one point it uses an array of pointers to doubles double **ibuffer as a parameter for a function.

So how do I pass this to a C DLL from Visual Basic? Preferably, I would create the array in VB, but I wouldn’t need to manipulate or use the values in VB. So basically, all VB needs to do is allocate the memory for the array of pointers. C would do all the other stuff. How can this be accomplished?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:25:06+00:00Added an answer on June 11, 2026 at 2:25 pm

    I assume that you are using pInvoke to call C method in VB.NET

    First of all, there is no default marshalling available for Jagged arrays which means that you will have to do your own custom marshalling which is a little complicated but not very difficult. Here is the code to do such a thing in C#. I am not that good with VB.NET Syntax so I am sure you would be able to convert this to VB.NET

    [DllImport( "yourdll.dll", EntryPoint="YourMethodName",  CallingConvention=CallingConvention.Cdecl)]
      static extern void YouMethodName(IntPtr matrix);
      static void Main( string[] args )
      {
         double[][] test_matrix = { new double[] {1.1,2.2},
                                    new double[] {3.3,4.4},
                                    new double[] {5.5,6.6}};
    
         IntPtr pa1 = marshalJaggedArray( test_matrix );
         YourMethodName( pa1 );
      }
    
      static private IntPtr marshalJaggedArray( double[][] array )
      {
         int sizeofPtr = Marshal.SizeOf( typeof( IntPtr ) );
         int sizeofDouble = Marshal.SizeOf( typeof( double ) );
    
         IntPtr p1 = Marshal.AllocCoTaskMem( array.Length * sizeofPtr );
         for ( int i = 0 ; i < array.Length ; i++ )
         {
            IntPtr v1 = Marshal.AllocCoTaskMem( array[i].Length * sizeofDouble );
            Marshal.Copy( array[i], 0, v1, array[i].Length );
            Marshal.WriteIntPtr( p1, i * sizeofPtr, v1 );
         }
         return p1;
      }
    

    Taken from : http://social.msdn.microsoft.com/Forums/is/csharplanguage/thread/dd729947-f634-44f4-8d91-11fcef97cabe

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a java project I want to create which will be built on
I have a method in my native dll, that I want to use. The
I have a C++ DLL that I wrote that has a single exposed function,
I'm working on an application so i have write an dll which contain a
I have a dll in C# which returns a class object. DLL code: Person.cs:
I have a DLL which outpus data to a stream. But it adds a
I have a DLL which cause to an error when I run the application.
we have a C++ Win32 DLL that reads data from Excel. The application uses
My coworker wrote a package in VB.NET to manipulate strings. I have been asked
I have an unmanaged DLL that gets called from .NET with pre-allocated buffers to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.