Access violation exeption when calling Resize from excel asynchronously

Dec 12, 2014 at 5:04 AM
I was working around getting data from webservice and displaying the table in excel.Here's the code for the same

[ExcelFunction("Get financial table")]
 public static object GetTable([ExcelArgument("Company Symbol")] string cmpSymbol,   [ExcelArgument("Report Name")] string reportType)
        ExcelReference exrf = XlCall.Excel(XlCall.xlfCaller) as ExcelReference;
        return ExcelAsyncUtil.Run("GetTable", new object[] { cmpSymbol, reportType },
                Dictionary<string, string> Args = new Dictionary<string, string>();
                Args.Add("prefixText", cmpSymbol);
                return GetData("GetSymbols", Args, exrf);

    public static object GetData(string Command, Dictionary<string, string> Args, ExcelReference exrf)
        var cogURL = @"url/" + Command;
        string data;
        using (var webConnection = new WebClient())
                webConnection.Headers[HttpRequestHeader.ContentType] = "application/json";
                data = webConnection.UploadString(cogURL, "POST", new JavaScriptSerializer().Serialize(Args));
            catch (WebException ex)
                throw new Exception("Unable to download the data! Check your Internet Connection!", ex);

        AjaxWrapper<string> dataObj = new JavaScriptSerializer().Deserialize<AjaxWrapper<string>>(data);

        List<Symbol> Symbols = new JavaScriptSerializer().Deserialize<List<Symbol>>(dataObj.d);
        object[,] excelData = new object[Symbols.Count, 2];

        for (int i = 0; i < Symbols.Count; i++)
            excelData[i, 0] = Symbols[i]ID;
            excelData[i, 1] = Symbols[i].Name;
        return excelData;
        //return ArrayResizer.Resize(excelData,exrf);
        //return XlCall.Excel(XlCall.xlUDF, "Resize", excelData, exrf);
I wanted to resize the cells according to the data so calling =Resize(GetTable("ACC",1)) works fine.But I wanted to achieve all by single function without nesting so added __XlCall.Excel(XlCall.xlUDF, "Resize", excelData, exrf)
but it is giving error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Any way to do this.

Thanks in advance.