Passing an Array from C# to VB.Net

Posted on 2007-10-03
Medium Priority
Last Modified: 2013-11-26
I need help converting a C# app to a C# dll.  I don't know C#, and I'm writing an app in vb.net, I need to be able to declare a public function in the C# dll.  I have a sample solution written in C# that gets EXIF data from images.  I need to be able to call it from a VB.Net app.  I'm using VS 2005.
I have created the dll, but the function that gets the data is not available in the vb app.
Here is some of the code.

public System.Collections.ArrayList GetExifTags(ImageXTagCollection a2)
System.Collections.ArrayList myArrayList = new ArrayList();
//Code to get ExifData
return myArrayList;

When I look at the object browser in the vb app, I can see the function, and it is public.  Why can I not use it?

Question by:Jimmy Lea
LVL 13

Accepted Solution

dungla earned 2000 total points
ID: 20011733
Did you add reference to C# dll from VB app?

Here is my sample class do the same thing:

=== C# DLL===
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace myDLL
    public class Utils
        public ArrayList GetTags(int count)
            ArrayList myArr = new ArrayList(count);
            for (int i = 0; i < count; i++)
                myArr.Add(i + 1);
            return myArr;

=== VB App===
Imports System.Collections
Public Class myForm

    Private Sub btnClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.Click
        Dim myUtils As New myDLL.Utils()
        Dim myArr As ArrayList
        myArr = myUtils.GetTags(5)
        For i As Integer = 0 To myArr.Count - 1
    End Sub
End Class

Author Comment

by:Jimmy Lea
ID: 20019345
That's it.
I missed 'Dim myUtils As New myDLL.Utils()'



Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question