Options

NAV2018 - AddIn "A Call to System.Object.get_XXXX failed with this message: The type of one ore ..."

Hi there,

working on NAV2018 CU06 I'm getting this error by trying to use a self programmed AddIn: A call to "System.Object.get_CallingSource failed with this message: The type of one or more arguments does not match the method's parameter type." I found some entries at the Net but nothing fixed this.

I'm on programming an AddIn an the error occurs by calling an event in C# which is returning selfmade EventArgs into NAV and using the returned parameter.property e.CallingSource which type is string.

Because of missing event in NAV-pages like "OnAfterLoad" I'm working with a short working timer. This is because on run.page the trigger "OnAfterGetCurrentRecord" is raised before the AddIn is visible. Maybe stupid but not depending on my problem.

Here I'm as a not really good developer in C#:

public class MyAddin : WinFormsControlAddInBase , IObjectControlAddInDefinition

{
[ApplicationVisible]
public event EventHandler <TimerEndReachedEventArgs> TimerEndReached = delegate { };
//I tried different version of this. " = delegate.." is a tip from the Net - without same error result

protected virtual void RaiseTimerEndReached(TimerEndReachedEventArgs e)
{

if (TimerEndReached != null)
{
TimerEndReached(this, e);
}

}

}

public class TimerEndReachedEventArgs : EventArgs
{
public string CallingSource { get; set; }
}



So the event in NAV-Page looks like this:

MyAddInControl::TimerEndReached(sender : Variant;e : DotNet ("MyAddIn.TimerEndReachedEventArgs")

MESSAGE('%1',e.CallingSource);


On raising the event in C# i get the error as describted.

I've wrote two moore events - calling without a timer, also with self made EventArgs - all thees are throwing the error.

Here is a part of the system log:

A call to System.Object.get_CallingSource failed with this message: The type of one or more arguments does not match the method's parameter type.
ExceptionStackTrace:
at Microsoft.Dynamics.Nav.Runtime.NavApplicationMethod.InvokeMethod(ITreeObject obj, String methodName, Object[] args, Boolean resolveHandler, Boolean throwOnNotFound)
at Microsoft.Dynamics.Nav.Service.NSField.InvokeEventTriggerInternal(NavSession con, String eventName)
at Microsoft.Dynamics.Nav.Service.NSField.InvokeEventTrigger(NavSession session, String eventName)
at SyncInvokeInvokeEventTrigger(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.RunInTransactionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs)
at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_0.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)


Anyone with ideas? Thank you!

Achim
Sign In or Register to comment.