Hello everyone,
I have a problem with my managed code. Basically I wanna do web request using RestSharp package from dynamic ax. Is it possible to do that?
I've created a managed code project that send a web request using RestSharp and I deployed them on client and server. I added RestSharp into my project via Nuget Package Manager.
But when I call the function, Ax returns error message:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
at ApprovalRequestHelper.ApprovalRequester.sendRequest(String url, String jsonToSend)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Dynamics.AX.ManagedInterop.ClrBridgeImpl.InvokeClrStaticMethod(ClrBridgeImpl* , Char* pszClassName, Char* pszMethodName, Char* assemblyName, Int32 argsLength, ObjectWrapper** arguments, Boolean* argsAreByRef, Boolean* isException)
So my method signature is: ApprovalRequestHelper.ApprovalRequester.sendRequest(String url, String jsonToSend)
I've check on the VSAssemblies folder and I see ApprovelRequestHelper dll. So there is nothing wrong with the dll and the function itself. From the error message, I think the error lies on the dependency of RestSharp.dll. Somehow it's not detected by AX or CIL (I dunno). Is the package dependency not deployed into AX together with my managed code dll when I deploy my project?
For what it's worth, I've enable hot-swapping assembly, Restart server. I've checked that if I remove the RestSharp package and the code that depends on it, My function runs without error.
Please enlighten me if you have any clue how to solve this. Thanks! If I ask on the wrong forum, I'm sorry.