FatalExecutionEngine error with 0xc0000005 Error Code on passing string array from vba to VSTO RRS feed

  • Question

  • Hi,

    I am getting FatalExecutionEngine error with  0xc0000005 Error Code on passing string array from VBA to VSTO.

    My interface in C# is shown below

        public interface IInterface1

           void SetStringArr(ref string[] str);


    While setting array from VBA as shown below,it gives me above FatalExecutionEngine error.

    Dim str(0) As String

    Call class1.SetStringArr(str)

    Please provide some assistance for the same.


    Tuesday, March 3, 2015 2:44 PM


  • Hi Dhiraj V,

    Since you metioned passing string array from VBA to VSTO, I assume you are calling code in VSTO solution from VBA.

    To pass the string array to the VSTO solution from other application, we can define a object parameter, then we can conver this object to the string array like code below:

       public void TestStringArray(object str)
                string[] newarr = Array.ConvertAll((object[])str, s => (string)s);
                for (int i = 0; i < newarr.Length; i++)
                    Globals.ThisAddIn.Application.ActiveSheet.Range["A" + (i + 1)].Value = newarr[i];
    VBA test code:
    Sub CallVSTOMethod()
        Dim addIn As COMAddIn
        Dim automationObject As Object
        Set addIn = Application.COMAddIns("ExcelAddIn1")
        Set automationObject = addIn.Object
    Dim myarray As Variant
    myarray = Array("Cat", "Dog", "Rabbit")
    automationObject.TestStringArray myarray
    End Sub
    Regards & Fei

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, March 4, 2015 7:52 AM