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 7182483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:46:48+00:00 2026-05-28T17:46:48+00:00

I am using a COM visible C# library that I call from VBA in

  • 0

I am using a COM visible C# library that I call from VBA in Excel. The C# method that is called includes arguments passed by ref. I am using VS2010, Office 2010, .Net framework 4.

  • In an earlier version of my Excel file, the call to the library works fine and still does.

  • In the newer version (the call itself to the C# library has not changed), VBA manages to call the library, however when the C# method finishes, I get a runtime Error 430 “Class doesn’t support Automation or does not support expected interface”. I used the DEBUG mode to see that. In that same file, VBA manages to call a deployed .NET library.

What I tried:
– Re-adding the reference to the OLE Automation library in VBA.
– Re-compiling the C# library

I am a bit puzzled as to what could be wrong and where. Excel itself does not seem to be the problem, since my older file works. The C# library is called from my older file too so the problem should not come from the library. As for the ability of my file to call COM visible libraries, well, the call to another C# library works (that one is deployed).

Any help would be much appreciated!


The VBA call to csharp is as follows:

Dim csharptoolsDispatch As Object
Set csharptoolsDispatch = CreateObject("Dispatch.Caller")
Dim a as string
ReDim input(0 to 5) as single 
ReDim output(0 to 5) as single 
a = csharptoolsDispatch.solveDispatch(2, False, input, output)

The C# looks like:

-Interface

namespace Dispatch
{
   public interface iCaller
   {
       string solveDispatch(int a, bool flag, float[] input, ref float[] output);
   }
}

-Class

namespace Dispatch
{
    [ClassInterface(ClassInterfaceType.None)]
    [ComVisible(true)]
    public class Caller : iCaller
    {
        public string solveDispatch(int a, bool flag, float[] input, ref float[] output)
        {    
           //code
           return "ok";
        }
    }
}

The call to the Csharp method works fine, the Csharp runs fine and just after the ‘return “ok”‘, when the “focus” is back on VBA I get the error 430 message.

  • 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-05-28T17:46:50+00:00Added an answer on May 28, 2026 at 5:46 pm

    Ok, I managed to sort it out.

    In hindsight, it was a pretty obvious mistake but weird behaviour from the COM interop interface between VBA and C# made it difficult to spot.

    In the VBA call to C#, among the arguments, there was a table of single which was defined as a table of int in C#. That argument was passed in ref.

    In such a case, I would expect VBA to crash saying ‘invalid argument’ or something. Instead, there seem to be an implicit cast of the single to an int that makes the call to C# possible.
    Then, when the csharp method finishes, VBA don’t seem able to make sense of the argument it passed in ref and that changed type. That causes the 430 error.

    My earlier version did not have that mistake and therefore worked.

    I have to remenber VBA is very weakly typed!

    Anyway, mystery solved!

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

Sidebar

Related Questions

I'm writing an Excel Addin using COM Interop from .net. I have a command
I've written a .NET DLL which is called from another application using COM interop.
I'm using a COM object that has a function called GetImage. http://www.pdf-tools.com/asp/products.asp?name=P2IA When I
I have to replace an existing dll call that is registered and called using
When using COM boolean values are to be passed as VARIANT_BOOL which is declared
What are profound advantages that one get when using COM for developing components over
Here's the core problem: I have a .NET application that is using COM interop
I have a simple class library that I use in Excel. Here is a
I'm using a Class Library exporting a function via COM. When calling this function
As part of writing custom command (COM-Visible dll with class that implements Interwoven command

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.