Error loading Ninject component ICache with Microsoft.AspNet.Identity 2.2.0 - ninject

With the recent update of Microsoft.AspNet.Identity.* to 2.2.0, NInject is not working properly anymore.
I get the following error (not finding any services registered in NInject)
Error loading Ninject component ICache
No such component has been registered in the kernel's component container.
Everything used to work just fine with the version 2.1.0. Could it be a bug introduced in Microsoft.AspNet.Identity? Or a remnant bug from NInject (if so, which package?)
Really similar to Error loading Ninject component ICache, but this just started happening since version 2.2.0
I use latest of all NInject on NuGet.
NInject 3.2.2.0
Ninject.MVC3 3.2.1.0
Ninject.Web.Common 3.2.3.0
Ninject.Web.Common.OwinHost 3.2.3.0
Ninject.Web.Common.WebHost 3.2.3.0

Related

Not able to load spartacus storefront after Upgrading spartacus from 3.0.0 to 3.3.0

After upgrading spartacus version from 3.2.0 to 3.3.0 getting below error while loading storefront. No error on Yarn build or server startup but only when trying to open storefront
errors visible in developers tool
Replace static property ModalService.rootComponent with a getter that is evaluated lazy (not during the service instantiation), but only when #modal method is called.
protected get rootComponent() {
return this.applicationRef?.components?.[0]?.location?.nativeElement;
}
See https://github.com/SAP/spartacus/issues/12632#issuecomment-852198709

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0 in Azure Functions

I have an API and a separate Azure Functions app. I upgraded my API app to .NET 5 and it's working fine. In the API app's solution, I have class library projects that I also reference in my Azure Functions app. These class libraries are netstandard2.1 projects.
Ever since this update -- during which I also updated all my NuGet packages to latest versions -- my Azure Functions app stopped working. I'm getting the following error:
Could not load file or assembly
'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot
find the file specified. Value cannot be null. (Parameter 'provider')
I noticed that there were breaking changes involving the Microsoft.Extensions.* packages and their recommendation is to install the package that is causing the issue directly. So I added Microsoft.Extensions.Configuration.Abstractions to my Azure Functions manually -- before it was being installed as a dependency of Microsoft.Extensions.Configuration package. Here's the information about this:
https://github.com/dotnet/aspnetcore/issues/21033
The issue still persists. I even tried downgrading Microsoft.Extensions.Configuration in both the API and Functions app, but I'm still getting the same error.
Any idea how to resolve this issue?
Sam's comment should be accepted as correct answer. I try it out to downgrade Microsoft.Extensions* (in my case Microsoft.Extensions.Logging.Console) from 5.0.0 to 3.1.0 and the error just gone.
Bravo!
If you are upgrading from .NET Core 3.1 to .NET 6 and you get this error, you need to change the Azure functions version to v4 and it fixes this error.
As a reference, this GitHub link explains exactly why that happens.
And as of now, you either track down the exact versions been referenced or downgrade everything to the latest v3 build.
In a nutshell, Azure Functions SDK already has some dependencies loaded in memory, so your libraries cannot use newer versions of the same libraries.
Adding this answer in case it helps anyone upgrading from .NET 3.1 to .NET 6.0.
First, as per #Jeff's answer, make sure you reference v4 in the Azure Functions project .csproj file:
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
In my case, however, this was already set.
The Azure Function was running fine locally however in Azure DevOps pipeline I was getting the error described by the OP.
I noticed that when debugging the Azure Function locally, the console was outputting:
Azure Functions Core Tools
Core Tools Version: 4.0.3928 Commit hash: 7d1d4a32700695bbf290a871c7492fde84bb767e (64-bit)
Function Runtime Version: 4.0.1.16815
In my case I am actually running the Azure Function in an Azure DevOps pipeline for e2e test purposes. To achieve this, I first install the Azure Function Core Tools on the build agent using this npm command:
npm install azure-functions-core-tools -g
However this installs azure-functions-core-tools#3.0.3904 (version 3.x - NOT the latest version 4.x).
I then installed Azure Function Core Tools (v4), e.g. by installing with this npm command.
npm i -g azure-functions-core-tools#4 --unsafe-perm true
And this (for me) resolved the error.
Whether or not this is your exact scenario, make sure you are using Azure Function Core Tools v4.x if using Azure Function Runtime v4 and .NET 6.
As #binaryDi mentioned in their answer, you need to downgrade packages that reference version 5 of Microsoft.Extensions.Configuration.Abstractions.
This can be a bit of a pain, as it doesn't tell you which packages are actually referencing Microsoft.Extensions.Configuration.Abstractions package/namespace.
For me, I had to update Microsoft.Extensions.Caching.Memory and Microsoft.EntityFrameworkCore.SqlServer to a version before 5. Anything that is referencing dotnet 5 should be downgraded for the Azure Function to run.
I stumbled upon this question while looking for an answer to my problem with upgrading to .NET 6.0. There was no going back, because I've bought a Macbook with an M1 processor and Arm support only works decently in .NET 6.0
Putting <AzureFunctionsVersion>v4</AzureFunctionsVersion> wasn't enough, because that doesn't increase the runtime version on Azure.
My function was already running on version 3.0 and strangely I couldn't select v4.0 in the portal. I had to change the version through the Azure CLI.
More information on how to do that can be found here: https://learn.microsoft.com/en-us/azure/azure-functions/set-runtime-version?tabs=azurecli
I also ran into this error when upgrading a c# function project from NETCORE 3.1 to .NET 6.
I set the following in the project (.csproj).
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
AND also changed the Application setting value in the Function App - Configuration Section (Azure Portal)
"FUNCTIONS_EXTENSION_VERSION" from "~3" to "~4"
and that fixed it for me.
I also ran into this error when upgrading a c# func project from version 3 to 4.
I had already set <AzureFunctionsVersion>v4</AzureFunctionsVersion> but that didn't solve it.
The answer by #neeohw pointed me to the solution that fixed it for me, but I had to dig a bit further, and this is what fixed it for me:
Do the Azure cli commands as specified here:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=in-process%2Cv4&pivots=programming-language-csharp#azure
I suggest you read that section for a background understanding, but the commands that ran was these:
az functionapp config appsettings set --settings FUNCTIONS_EXTENSION_VERSION=~4 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>
# For Windows function apps only, also enable .NET 6.0 that is needed by the runtime az functionapp config set --net-framework-version v6.0 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>
The issue was occurring to me, when I was trying to host an upgraded function in Azure functions. The previous version was targeted to netcoreapp3.1, which I upgraded to target net6.0 and, set v4 as Azure Function version.
The error was
"Could not load file or assembly 'Microsoft.Extensions.Configuration', Version=6.0.0.0 in Azure Functions"
After spending couple of hours, I figured that its the startup class that was causing the issue because it was the only place Configuration was used.
Changing the Startup to inherit from FunctionsStartup rather than WebJobsStartup, fixed the issue.
And with slight adjustments, it worked.
[assembly: FunctionsStartup(typeof(Startup))]
...
public class Startup : FunctionsStartup { ...
public override void Configure(IFunctionsHostBuilder builder)
{
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddHttpClient();
...
}
That's it!
I had the same issue and the configuration for Azure FunctionsVersion was already present.
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
I was able to resolve the issue by downgrading the version of Microsoft.Extensions.Http from 7 to 6
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
I was this error on my Mac (arm) when I tried to ran my functions (.NET6) locally.
In my case, I tried your solution and the functions still would not start and I still had this log in the console: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified..
I realized that I had installed 2 instances of azure tools (v3 with HomeBrew and v4 with npm).
When I run func start to start my functions, I observed that v3 was used. So I uninstalled the v3 tools with HomeBrew to use v4 with npm).
In my case, the reason was Microsoft.EntityFrameworkCore version 5.0.2.
I donwgraded it to version 3.1.18.
(Other related packages, such as Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.SqlServer, and Microsoft.EntityFrameworkCore.Tools should also be downgraded to 3.1.18.
I had this error when I used the latest of version Npgsql.EntityFrameworkCore.PostgreSQL which is 5.0.7 as this time of writing. I had to downgrade to 3.1.11 for the current version has a dependency to the 5.0.0.0 version of
Microsoft.Extensions.Configuration.Abstractions.

Ninject Error activating HttpConfiguration

I have added the NuGet package: Ninject.Web.WebApi.WebHost to my ASP.NET Web API project, however, once I add all of my DI bindings, I get the following error message:
Error activating HttpConfiguration More than one matching bindings are available. Matching bindings:
1) binding from HttpConfiguration to method
2) binding from HttpConfiguration to method
Activation path: 1) Request for HttpConfiguration
Suggestions: 1) Ensure that you have defined a binding for
HttpConfiguration only once.
These are the NuGet packages that are added along with Ninject.Web.WebAPI.WebHost:
Ninject v. 3.2.2
Ninject.Web.Common v. 3.2.3
Ninject.Web.Common.WebHost v. 3.2.3
Ninject.Web.WebApi v. 3.2.4
Ninject.Web.WebApi.WebHost v. 3.2.4
I have no idea how to resolve this since I was able to get this to work on previous projects, but this project does not seem to be working for whatever reason.
I also encounter this error message frequently with all of these versions of the assemblies:
Make sure that the controller has a parameterless public constructor
Sometimes I am able to build the project correctly with older versions of the Ninject assemblies, but I frequently get the error message:
Sequence contains no elements.
The only way I have discovered to resolve this error is to delete the bin directory and re-build, but I don't understand why I constantly have to delete the bin directory to get Ninject to work properly each time.
Please advise as to how to get Ninject to work properly with Web API v.2.2
I found the solution to this over here.
In short, the solution is to get all Ninject packages to the same version. There was a shuffling around of the HttpConfiguration stuff and if you have different versions of different Ninject packages, it can exist in multiple places. Upgrading everything to the same version should resolve this.

Worklight 5.0.6 Dojo code migration

I have develop a simple application on worklight 5.0.5 and it's working fine but after updating to version 5.0.6 I am facing some issues. When I launch the application dojo's libs are not integrated with my application.
Can any one help me regarding this? Thanks,
It give me the following error
Uncaught TypeError: Object function klass() {
this.initialize.apply(this, arguments);
} has no method 'setConnected'
See the Worklight 5.0.6 InfoCenter for details on code migration when you upgrade: http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/topic/com.ibm.worklight.help.doc/devenv/r_migrating_to_a_newer_version_of_ibm_worklight.html
If you created your current project with an earlier version of IBM
Worklight Studio, consider migrating the code to the new Dojo module
loading technique in addition to upgrading the Dojo toolkit. It
ensures that the code performs more reliably and that the page
continues to work when it makes further changes in RPE.
Specifically, the Dojo layers are no longer loaded from HTML elements,
but instead they are loaded by require() calls inside the
wlCommonInit() method. The individual modules are loaded from
require() calls inside the dojoInit() method.
Here is the link to the specific Dojo 1.8.3 code changes: http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m6/topic/com.ibm.worklight.help.doc/devenv/t_dojo_183_code_migration.html

Ninject and MonoDroid

Anyone had any luck getting Ninject to work on MonoDroid? i've tried the 2.0 and 4.0 mono builds from their website and also tried the .net versions.
With the Mono builds i'm getting a MissingMethodException in the instantiation of my StandardKernel
I am experimenting with Ninject on a combined WP7/Monotouch/Mono for Android project and Ninject works surprisingly good.
I used the latest sources, which contain a project file Ninject.WP7.csproj which seems to be outdated. It contains a lot of DefineConstants. I created new WP7/Monotouch/Mono for Android solutions with these constants and everything compiled and works!
Constants used:
SILVERLIGHT,SILVERLIGHT_40,NO_LCG,NO_ASSEMBLY_SCANNING,NO_WEB,NO_PARTIAL_TRUST,NO_SKIP_VISIBILITY,NO_EXCEPTION_SERIALIZATION,NO_DEBUG_SYMBOLS
not sure if they are all needed, but the SILVERLIGHT one is important because Monotouch/Mono for Android implement a large part of the Silverlight api.
Of course you cannot create Android Activities with Ninject. I use it mainly for constructor injection, to create .Net objects like a ViewManager, view models using a repository, etc., the usual things you do with dependency injection.
I haven't tried to get Ninject working, but I'd be very surprised if it just worked out of the box. If there's a Silverlight build of Ninject you may have more luck with that, but there are no guarantees. The "best" way to get support for it in Mono for Android would be to build the code against the Mono for Android profile as a class library.
That said, there are other options out there for doing service location in your apps. I have a blog post up here that talks about using TinyIoC and Funq for service location.