public static object CallMethod( [ExcelArgument(Name = "ObjectHandle", Description = "Handle to an object.")] string h, [ExcelArgument(Name = "Method", Description = "Name of the method that will be called.")] string m, [ExcelArgument(Name = "[Args1]", Description = "Parameter to be passed to the specified function.")] object o1, #region optional args 2 - 28 [ExcelArgument(Name = "[Args2]", Description = "Parameter to be passed to the specified function.")] object o2, [ExcelArgument(Name = "[Args3]", Description = "Parameter to be passed to the specified function.")] object o3, [ExcelArgument(Name = "[Args4]", Description = "Parameter to be passed to the specified function.")] object o4, [ExcelArgument(Name = "[Args5]", Description = "Parameter to be passed to the specified function.")] object o5, [ExcelArgument(Name = "[Args6]", Description = "Parameter to be passed to the specified function.")] object o6, [ExcelArgument(Name = "[Args7]", Description = "Parameter to be passed to the specified function.")] object o7, [ExcelArgument(Name = "[Args8]", Description = "Parameter to be passed to the specified function.")] object o8, [ExcelArgument(Name = "[Args9]", Description = "Parameter to be passed to the specified function.")] object o9, [ExcelArgument(Name = "[Args10]", Description = "Parameter to be passed to the specified function.")] object o10, [ExcelArgument(Name = "[Args11]", Description = "Parameter to be passed to the specified function.")] object o11, [ExcelArgument(Name = "[Args12]", Description = "Parameter to be passed to the specified function.")] object o12, [ExcelArgument(Name = "[Args13]", Description = "Parameter to be passed to the specified function.")] object o13, [ExcelArgument(Name = "[Args14]", Description = "Parameter to be passed to the specified function.")] object o14, [ExcelArgument(Name = "[Args15]", Description = "Parameter to be passed to the specified function.")] object o15, [ExcelArgument(Name = "[Args16]", Description = "Parameter to be passed to the specified function.")] object o16, [ExcelArgument(Name = "[Args17]", Description = "Parameter to be passed to the specified function.")] object o17, [ExcelArgument(Name = "[Args18]", Description = "Parameter to be passed to the specified function.")] object o18, [ExcelArgument(Name = "[Args19]", Description = "Parameter to be passed to the specified function.")] object o19, [ExcelArgument(Name = "[Args20]", Description = "Parameter to be passed to the specified function.")] object o20, [ExcelArgument(Name = "[Args21]", Description = "Parameter to be passed to the specified function.")] object o21, [ExcelArgument(Name = "[Args22]", Description = "Parameter to be passed to the specified function.")] object o22, [ExcelArgument(Name = "[Args23]", Description = "Parameter to be passed to the specified function.")] object o23, [ExcelArgument(Name = "[Args24]", Description = "Parameter to be passed to the specified function.")] object o24, [ExcelArgument(Name = "[Args25]", Description = "Parameter to be passed to the specified function.")] object o25, [ExcelArgument(Name = "[Args26]", Description = "Parameter to be passed to the specified function.")] object o26, [ExcelArgument(Name = "[Args27]", Description = "Parameter to be passed to the specified function.")] object o27, [ExcelArgument(Name = "[Args28]", Description = "Parameter to be passed to the specified function.")] object o28 #endregion ) { object res = ExcelError.ExcelErrorNA; if (_cache.ContainsKey(h)) { object or = null; CacheItem handle = _cache.Lookup(h) as CacheItem; CacheItemMethod cim = handle.CacheType.Method(m); Exception e = handle.CacheType.Exception; object[] input = null; if (e == null) { Type[] parTypes = cim.Parameters.Select(s => s.ParameterType).ToArray(); if (parTypes.GetLength(0) > 0) { input = ParameterCleaner.MultArgs(parTypes, out e, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14, o15, o16, o17, o18, o19, o20, o21, o22, o23, o24, o25, o26, o27, o28); } or = handle.Call(m, input); e = handle.Exception; if (e != null) { string inner = (e.InnerException == null) ? string.Empty : e.InnerException.Message; res = string.Format("{0} {1}", e.Message, inner); } else { res = or; } } else { res = e.Message; } } return(res); }