-
-
Notifications
You must be signed in to change notification settings - Fork 292
Description
Hello,
We're running version 1.9, and we are seeing some weird exceptions when upgrading our addin by first unregistering the old DLL and registering the new DLL.
We get this when registering:
"Expression of type 'Pricing.Models.ExpiryKey' cannot be used for parameter of type 'Pricing.Models.ExpiryKey' (Parameter 'arguments[2]')"}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147024809
HelpLink: null
InnerException: null
Message: "Expression of type 'Pricing.Models.ExpiryKey' cannot be used for parameter of type 'Pricing.Models.ExpiryKey' (Parameter 'arguments[2]')"
ParamName: "arguments[2]"
Source: "System.Linq.Expressions"
StackTrace: "
at System.Dynamic.Utils.ExpressionUtils.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arguments, ParameterInfo pi, String methodParamName, String argumentParamName, Int32 index)\r\n
at System.Dynamic.Utils.ExpressionUtils.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments, String methodParamName)\r\n
at System.Linq.Expressions.Expression.Invoke(Expression expression, IEnumerable`1 arguments)\r\n
at ExcelDna.Registration.ParameterConversionRegistration.ApplyConversions(ExcelFunctionRegistration reg, List`1 paramsConversions, List`1 returnConversions)\r\n
at Derivatives.Excel.Utilities.Addin.Register() in C:\\src\\excel-addin\\Derivatives.Excel.Utilities\\Addin.cs:line 55"
TargetSite: {System.Linq.Expressions.Expression ValidateOneArgument(System.Reflection.MethodBase, System.Linq.Expressions.ExpressionType, System.Linq.Expressions.Expression, System.Reflection.ParameterInfo, System.String, System.String, Int32)
We have a ExpiryKey type with custom parameter converters.
We have Excel functions using this type.
For functions with less than 16 parameters, all good.
[ExcelFunction(Name = "GetFwd")]
public static object GetFwd(
ExpiryKey expiry,
IReadOnlyDictionary<string, object> priceDriver,
object calendar,
object valueDate)
{ }
For functions with more than 16 parameters, we get the exception above:
[ExcelFunction(Name = "SearchStrikeWithDelta")]
public static object SearchStrikeWithDelta(
string callPut,
ExpiryKey expiry,
string underlying,
string rateCurve,
string mic,
DateTime valueDate,
object vols,
object rates,
object priceDriver,
object calendar,
double targetDelta,
string deltaType,
object borrowCurve,
object dividends,
object instrumentValuationParams,
object instruments,
object volEvents,
object deliverableExpiry = null)
{ }
If I remove the ExpiryKey parameter, I still have a functions with more than 16 parameters but it gets registered successfully..
Strange.
Not sure if this has something to do with Expression.GetDelegateType which can only create delegate types with up to 16 parameters.
It seems like the old ExpiryKey type is still loaded and clashes with the new one... (although this type definition hasn't changed between old and new version).
We have hundreds of users so we can't change the signature of our functions unfortunately.
Thank you!