error referencia.net 4.6.1 for O. netStandart 2.0
I'm having a problem referencing a Standart2. 0 project to my .NET Framework 461 api;
Occurs the following I have the Class:
public class MeuReturn : IHttpActionResult
{
private readonly string _objeto;
public MeuReturn(string objeto)
{
_objeto = objeto;
}
public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
{
HttpResponseMessage response =
new HttpResponseMessage(HttpStatusCode.BadRequest)
{
Content = new StringContent(_objeto)
};
return Task.FromResult(response);
}
}
To make a custom return, it works 100% but when I reference the other project and squeegee the API the following error occurs:
An error occurred. Method ExecuteAsync in Type WebApplication3.Controllers.Assembly MeuReturn WebApplication3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null it does not have an implementation. System.TypeLoadException on WebApplication3.Controllers.HomeController.error() in lambda_method (Closure , Object , Object[] ) in System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor. c _ _ DisplayClass10.b _ _ 9 (Object instance, Object [] methodParameters) in System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute (Object instance, Object [] arguments) em System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync (HttpControllerContext controllerContext, IDictionary ' 2 arguments, CancellationToken cancellationToken) - - - end of previous location stack trace where the exception was raised - - - in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task) in System.Web.Http.Controllers.ApiControllerActionInvoker.d _ _ 0.MoveNext() --- End of stack trace from previous location where exception was raised - - - in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task) in System.Web.Http.Controllers.ActionFilterResult.d _ _ 2.MoveNext() --- End of stack trace from previous location where exception was raised - - - in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task) in System.Web.Http.Dispatcher.HttpControllerDispatcher.d _ _ 1.MoveNext()
I checked again the Microsoft website and theoretically are compatible
1 answers
Edit the ClassLibrary.csprj, and add the target of your web application. remembering that the tag is in the plural: TargetFramerowk s