I have tried setting up Ninject.Web.Mvc.FluentValidation in my ASP.NET MVC4 project
as shown below:
var ninjectValidatorFactory = new NinjectValidatorFactory(kernel);
//ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new NinjectValidatorFactory(kernel)));
FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = ninjectValidatorFactory);
DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
but I am getting the below errors:
Error 1 The type 'FluentValidation.ValidatorFactoryBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'FluentValidation, Version=2.0.0.0, ...
Error 2 Cannot implicitly convert type 'Ninject.Web.Mvc.FluentValidation.NinjectValidatorFactory' to 'FluentValidation.IValidatorFactory'. An explicit conversion exists (are you missing a cast?)
I can see the NuGet Package for Ninject.Web.Mvc.FluentValidation is version 3.0.0.0
and the error is telling me it is looking for version 2 of FluentValidation for its dependency.
If I install the NuGet package just for Ninject.Web.Mvc.FluentValidation then it installs the FluentValidation v2 dependency rather than version 3.4.6
but I can also see here: https://github.com/ninject/ninject.web.mvc.fluentvalidation/commit/82096d0afd15c41d01c09fd47f4247682261768e
a note about the project being updated for version 3.4.6
I am currently using NuGet to add the FluentValidation.MVC4 package to my project and then adding Ninject.Web.Mvc.FluentValidation after it (which finds it's dependency already exists and doesn't add it).
I can see that the NuGet package was last published on the 1st April 2013 but when I look at the .nuspec file in my project it shows
<dependency id="FluentValidation" version="3.2.0.0" />
Is there anything I have done wrong with this setup? or a way I can get this working through the package manager console to update the dependency version?
UPDATE: The reason for this is because Ninject.Web.Mvc.FluentValidation is using the signed version of FluentValidation which is strongly named.
David Ebbo has a good post about strong names and binding redirects here
http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html
I still did not bother doing this to fix my problem, the NuGet package only has 1 class, the NinjectValidatorFactory, so it's worth just implementing your own.
To fix my problem for now I have put the NinjectValidatorFactoryclass into my own project. This looks to me like the current NuGet package needs to be updated further before it uses FluentValidation 3.4.6.
enter these codes in Package Manager Console :
Install-Package FluentValidation-Signed
Install-Package FluentValidation.MVC3-Signed -IgnoreDependencies
Install-Package Ninject.Web.Mvc.FluentValidation -IgnoreDependencies
-IgnoreDependencies is important .
Related
I want to run my app in xamarin.forms but I faced this problem
Error XA2002: Can not resolve reference: Microsoft.Bcl.AsyncInterfaces, referenced by SimpleInjector. Please add a NuGet package or assembly reference for Microsoft.Bcl.AsyncInterfaces, or remove the reference to SimpleInjector. 0
I'm using Couchbise.Lite packages as Database for my app
I'm using VS2022
I installed the package Couchbase.Lite on my side(with VS 2022) and figured out that the error only happened on Version 3.0.0.Using Version 2.8.6 or below is functioning well.
Today, I upgraded my projects to netcoreapp 2.1 to 2.2.
After that, my projects using Microsoft.AspNetCore.Identity give me an error:
error CS0234: The name or namespace name 'Identity' does not exist in the 'Microsoft.AspNetCore' namespace (are you missing an assembly reference?)
If I add the Microsoft.AspNetCore.Identity nuget package in project reference, I don't have any error with using directive, but I have always error on cannot found IdentityUser
I also cleaned nuget cache on my machine
My code is here: https://github.com/SOFTINUX/Base
(If, you would try to reproduce, you need to restore npm packages in Barebone project before build)
So, in netcoreapp 2.2, Microsoft.AspNetCore.Identity is not found. With netcoreapp2.1, I have no problems.
I want to use Identity into my app with netcore2.2, but I not found any informations about changes on it and I tested with example app in netcoreapp2.2 and I have no problem with it.
I supppose, the problem come from my project, but I dont see nothing
Thanks.
I've just cloned it and tried building it.
The error shows, that the namespace Microsoft.AspNetCore.Identity is missing in the SoftinuxBase.Security.Data.Entities project and that the compiler cannot find a reference for IdentityUser<T> and IdentityRole<T> both of which reside inside the Microsoft.AspNetCore.Identity.EntityFrameworkCore package.
So to resolve your error add the this package to your entities project, either through project reference or package manager console:
install-package Microsoft.AspNetCore.Identity -ProjectName SoftinuxBase.Security.Data.Entities
install-package Microsoft.AspNetCore.Identity.EntityFrameworkCore -ProjectName SoftinuxBase.Security.Data.Entities
The EntityFrameworkCore package has a dependency on the base Identity package and should pull that in implicitly, I've just added in the install-package command for clarity. In theory you should get away with just pulling in The EF package.
After getting rid of all the other small issues like the missing Microsoft.AspNetCore.StaticFiles package, I can compile the solution and get greeted by the following browser window:
So I suppose that this resolves your issue.
I am using NuPack (https://www.nuget.org/packages/NuPack/) to create a Nuget automatically on build but when I go to upload my Nuget file, it gives me this error:
Invalid package version for a dependency with id 'Newtonsoft.Json' in package 'Float.1.0.0': ''.
What is the error telling me?
How do I fix the issue?
I am not familiar with NuPack, but usually you'd have a a nuspec and need to specify the version of your dependency:
https://learn.microsoft.com/en-us/nuget/schema/nuspec#dependencies
Look for your Newtonsoft.Json entry and provide a version following these guidelines:
https://learn.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards
I'm trying to call loggerFactory.AddSerilog(); as per this documentation, but the AddSerilog method is not recognized:
"Error CS1061 'ILoggerFactory' does not contain a definition for 'AddSerilog' and no extension method 'AddSerilog' accepting a first...".
I'm using ASP.NET CORE with the full .NET framework.
What am I doing wrong?
You may forget this following line in project.json
"Serilog.Extensions.Logging": "1.0.0",
See also https://carlos.mendible.com/2016/09/19/step-step-serilog-asp-net-core/
Different circumstance, but same problem. In my case, I was using .Net Core 2.1 and had a NuGet reference to Serilog, but was missing a reference to Serilog.AspNetCore. The issue first manifested as .UserSerilog() not being found for the IWebHostBuilder of my CreateWebHostBuilder static method under Program.cs.
Adding the Serilog.AspNetCore NuGet package to my project solved the problem.
The posted answer is correct but I will add that you may want to use the NuGet package manager that way you can get the latest version.
Right click on solution
-> Choose "Manage NuGet packages for solution"
-> type "serilog.extensions.logging" into search box
-> Click on Serilog.Extensions.Logging and press install
You will get a dropdownlist of the different versions you should choose the latest.
Or quicker from Package Manager console verify that Default Project drop-down has your project selected and run
install-package Serilog.Extensions.Logging
On .NET Core 3.1, within a console app, I simply had to install the serilog.extentions.hosting NuGet package.
This will add the below line to the ItemGroup within YourProjectName.csproj
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.7" />
If you have package Serilog.Extensions.Logging added to your project already, it could be just a matter of adding using Serilog; to the top of your code file.
I am trying to locate PerRequestLifetimeManager. In MSDN, it says that it is part of the Unity 3 assembly.
I've installed Unity.Mvc4 via Nuget. The package.config says I am using Unity 3.0:
The Microsoft.Practices.Unity.dll says I am using Unity 3.0
I looked inside the DLL using object browser, and the PerRequestLifetimeManager is no where to be found.
Am I missing something here?
If someone will suggest an alternative class, I am planning to use a custom PerRequestLifetimeManager found here (if I am unable to find the class).
EDIT:
I've uninstalled Unity.Mvc4 and directly installed the Unity3.0 in the package console, here is what I got:
PM> Install-Package Unity -version 3.0.1304.1
'Unity 3.0.1304.1' already installed.
Successfully added 'Unity 3.0.1304.1' to RedLions.Presentation.Web.
I still can't find the PerRequestLifetimeManager class, even in the official library.
It seems not good to answer my own question when I just instead did it on my own. I can no longer delete my question.
Anyway, here was my solution.
I went straight to the source code of Unity, I found out that the class does exist in the same namespace but not in the same assembly. PerRequestLifetimeManager is in Microsoft.Practices.Unity.Mvc
I checked MSDN and it did say that its in a different DLL, which I failed to notice. Sorry about that.
It is not part of the Unity package in nuget, but in a different package in Nuget (Unity.Mvc), so here it is: http://www.nuget.org/packages/Unity.Mvc/
I decided to dump Unity.Mvc4 as it is no longer needed, everything is already in the Unity.Mvc. (App_Start/UnityConfig.cs)
you can delete the original DLLS and Uninstall the reinstall.
Run the following from PCM, Package Manager Console:
Install-Package Unity.Mvc
This will give you the DLL Microsoft.Practices.Unity.Mvc where it is.