Problem description: I created an MVC API which will be called with a WPF application or a xamarin.forms app. The call itself results in no error if I don't call the function with an object. I had a running version a bit longer ago and it also was a different solution. Now I have instead of 2 .NET Framework shared projects 2 .NET Standard projects. This project doesn't contain any server logic. They contain only the database and transfer objects. To transmit objects I use Newtonsoft.Json
PostAsJsonAsync(path, object)
Now there are 2 type of problems:
- First if I leave everything as it is, the methods with no parameters will be called without problems. But if I try to call a method with an object it will resolve the following error (this is the error message which the server returns, I'm 99% sure that the client does have no problems, because if I try the same method on the old solution it runs *1):
{"Message":"Fehler","ExceptionMessage":"Methode nicht gefunden: \"Void System.Web.Http.HttpResponseException..ctor(System.Net.Http.HttpResponseMessage)\".","ExceptionType":"System.MissingMethodException","StackTrace":" bei RohrAG.Inspect.Server.Api.Controllers.VerificationController.Login(LoginDto loginDto)\r\n bei lambda_method(Closure , Object , Object[] )\r\n
bei System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n bei System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n bei System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---\r\n bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n bei System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---\r\n bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n bei System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---\r\n bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n bei System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"}
- I can resolve this error by double click the server warning, which is the following:
Severity Code Description Project File Line Suppression State Warning Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: MySolution.Api *2
After it added a lot of dependentAssemblies it is working halfway. I can send objects to the server without receiving an error message but the object that the server receives is null. (I'm still sure that the client is functionally! I tried to call a method on a different solution with an object and where the server is receiving the object without problems.)
*1 I tried to copy the old project to the new solution. Didn't worked anymore. I also created a new project with the same settings to prevent any move errors, doesn't work either
*2 Somehow stackoverflow isn't showing the full message in the preview (It tells me it does look like spam so^^). If it stays like this, the warning just tells me that there are somehow problems with dependentAssembly. My web.config contains this before the fix: assemblyBinding before fix