Hi I have issue with Fluent Validation and the IOC container
I want to use FluentValidator on my BackEnd Service and in my Xamarin.Forms Apps.
I start with the BackOffice solution:
When Any method it my ApplicationService (I use swagger to test) I have this exception
"responseStatus": {
"errorCode": "Exception",
"message": "Error trying to resolve Service 'LanBO.ServiceInterface.ApplicationService' or one of its autowired dependencies (see inner exception for details).",
"stackTrace": " at Funq.Container.ResolveImpl[TService](String name, Boolean throwIfMissing)\n " +
"at lambda_method(Closure , IResolver )\n " +
"at ServiceStack.Host.ContainerResolveCache.CreateInstance(IResolver resolver, Type type, Boolean tryResolve)\n " +
"at ServiceStack.Host.ServiceController.<>c__DisplayClass37_0.<RegisterServiceExecutor>b__0(IRequest req, Object dto)\n " +
"at ServiceStack.Host.ServiceController.<ExecuteAsync>d__47.MoveNext()\n--- End of stack trace from previous location where exception was thrown ---\n " +
"at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\n " +
"at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\n " +
"at ServiceStack.Host.RestHandler.<ProcessRequestAsync>d__14.MoveNext()"
So I start by doing an Interface Class of my dto/table Data in a separate project
namespace LanBO.ServiceModel.Interface.Tables
{
public interface IApplication: IConcurrency
{
string ApplicationCode { get; set; }
string ApplicationDescription { get; set; }
bool Active { get; set; }
}
}
Then my Validator in a separate project:
namespace LanBO.FluentValidator
{
public class ApplicationValidator: AbstractValidator<IApplication>
{
public ApplicationValidator()
{
RuleFor(instance => instance.ApplicationCode)
.NotNull()
.NotEmpty();
RuleFor(instance => instance.ApplicationDescription)
.NotNull()
.NotEmpty();
}
}
}
In my service where the Exception occur I do have
using System;
using FluentValidation;
using LanBO.FluentValidator;
using LanBO.ServiceModel;
using LanBO.ServiceModel.Tables;
using ServiceStack;
using ServiceStack.OrmLite;
namespace LanBO.ServiceInterface
{
public class ApplicationService : Service
{
public IValidator<ApplicationValidator> ApplicationValidator;
public ApplicationService(IValidator<ApplicationValidator> appl)
{
ApplicationValidator = appl;
}
…
In my Apphost Configuration I have
appHost.Plugins.Add(new ValidationFeature
{
ScanAppHostAssemblies = false // Because I use a different Assembly to store my Validator
});
appHost.Container.RegisterValidators(typeof(ApplicationValidator).Assembly);
How can I debug this so I can see what assembly is missing ? I had in my project reference all the assemblies of my solution
Thanks!