Passing an Array from C# to VB.Net

Posted on 2007-10-03
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, 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

    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
    That's it.
    I missed 'Dim myUtils As New myDLL.Utils()'



    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now