'ExcelDna use ExcelDnaUtil.Application in other class report error System.InvalidOperationException
I hava a UDFGenerator class and a UDFtest class,in UDFGenerator I created a static variable based on ExcelDnaUtil.Application, and use it in a static function, if that all in the UDFGenerator it's worked ,but when I call UDFGenerator's function in UDFtest , it's wrong.
public static class UDFGenerator
{
public static readonly Excel.Application ExcelApp = ExcelDnaUtil.Application as Excel.Application;
public static async Task<object[,]> GetApiResult(string id, string ApiType,string paramListStr, object[] paramList){
...
}
}
public static class UDFtest
{
public static object GETROOT(object p0, object p1)
{
return ExcelAsyncUtil.Run("GETROOT", new object[] { p0, p1 }, delegate
{
return UDFGenerator.GetApiResult("001659ca6e3ed001d9a9be59d903a15c", "2", "NM,ENM", new object[] { p0, p1 }).GetAwaiter().GetResult();
});
}
}
How could I fix it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
