NinjectWebCommon.cs file is not adding after install ninject nuget package - asp.net-web-api2

I am using one web api application where i need to add ninject for dependency injection. I have gone through this Link where steps is mentioned one by one to use ninject. Currently i am using MVC 5 so for that i found ninjectMVC5 in nuget. I installed it but according to this link i should have get NinjectWebCommon.cs file in App_Start folder but did not get any file there to register our component.
I uninstalled all the ninject packages and found another link and followed there steps but still ninjectwebcommon.cs file is not finding in app_start folder.
Can someone explain here what i am doing wrong?
Thanks,
Vikash

This issue on github says that downgrading Ninject to version 3.2.3 should resolve the issue. Another option is to add the NinjectWebCommon.cs manually.

Related

Installing UCommerce on Sitefinity and it Throws NewtonSoft.json Error

So, Here is the actual issue. I have created a sitefinity project through Sitefinity Project Manager and after running it, i open the project files into my visual Studio 2019. I checked till here that everything is working fine and it was. Now when i go for installing Ucommerce on the project through Nuget packages. The package is Ucommerce.Sitefinity after installation it simply throws this error whenver i run it. Even when i removed the package the problem was still there.
Its like the Ucommerce package corrupts the project completely.. I have tried resolving it by searching on the internet but somehow it seems the solutions which worked for others are not for me as my project is not a simple asp.net project rather a sitefinity project, I may be wrong. Most of the solutions which i tried are from this thread here : Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference But as i said all in vain. Please help me with this as i need to get started with my development on the ucommerce for a project. Thanks in advance.
Also After removing the nuget package the Values for the Version changed from 6.0.0.0 to 12.0.0.0 .
Try manually deleting all files from the bin folder and then build again.
Probably there was an assembly that referenced an old version of the newtonsoft dll.
Finally, check the runtime bindings in web.config for the version of newtonsoft dll there.
Make sure it points to the version that is inside your packages.config file.

the project must provide a value for configuration Error when install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation in Core3.1

When I install Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation in a Web project and in Startup add :
services.AddMvc().AddRazorRuntimeCompilation();
,the project does not run and the error is:
the project must provide a value for configuration
my .NET-Core version is 3.1
How can this be fixed?
There are some GitHub issues with this problem and some solutions that have worked for people. That said I would check to see that all NuGet packages are on versions supported by .NET Core 3.1. At this particular moment that means not too new so as to only work with .NET 5 and not too old so as to only work with Core 2.2.
Otherwise, someone suggested restarting VS.
https://github.com/dotnet/sdk/issues/9932
You may also try deleting Microsoft.AspNetCore.Razor.Design from the CsProj file per this duplicate question

Kestrel fail: Can not load Microsoft.Extensions.Logging.Abstractions

I had a very simple Kestrel / ASP.NET Core project successfully deployed to my Windows 2008 R2 server.. (started with an empty Web project + IdentityServer4 nuget I was following this Getting Started page)
So, I could initially retrieve the 'discovery' JSON document.
Then, (per this guide) I added a couple of NuGet packages to it, some views/CSS, etc...
Microsoft.AspNetCore.Mvc -Version 1.1.0
Microsoft.ApsNetCore.StaticFiles -Version 1.1.0
The upgraded solution runs fine on my Win7 dev box, but, after redeploying.. Now I get the dreaded 502.5 error page. If I go into the server and try to "jump start" the executable via command line.. I can see this error:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=1.1.1.0, Culture=neutral,PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) at Ross.Web.Applications.Identity.Program.Main(String[] args)
Where did I go wrong?
I can see the aforemetioned DLL, Microsoft.Extensions.Logging.Abstractions, published to the server's file system. I'm guessing I need to do a binding redirect or something, but, I'm too new to core to know how.
UPDATE
After upgrading my NuGet packages to the latest.. the error is similar, but now it can't find: Microsoft.AspNetCore.Hosting.Abstractions, Version=1.1.2.0
People that have multiple projects in solution, pay attention:
This is mainly because there are multiple projects in your solution, and the mentioned package is installed in both of them but with different versions.
Suppose that the exception is like the following:
Simply stop debugging and go to the Manage NuGet Packages for Solution and search for that package in the installed tab:
As you can see, I have that package in two projects with different versions, and that's the point! Simply update the lower version equal to the higher version and you're all set.
Ok, I had to clear out my server's directory.. and do a fresh redeploy.
I had seen other answers about deleteing the 'bin' but was confused, since core web deployments don't feature an actual /bin directory.
Now, I take that to mean, "Clear out the binaries.. wherever they may be"
This is a common issue when mixing 1.1.0 and 1.1.1 asp.net core dependencies.
The simplest solution is to update all dependencies to 1.1.1. If this isn't possible, then you will need to add a binding redirect to redirect the 1.1.1 dependencies to target 1.1.0 assemblies.
After you change these dependencies or add the binding redirects, clear out you /bin folder locally, and turn clean on your next build.

How do I stop Ninject for WebApi failing on "var kernel = new StandardKernel();"

I just installed Ninject.MVC5 into my solution (I have an MVC project and a WebApi project in there and I wanted Ninject for both).
Then I installed WebApiContrib.IoC.Ninject to build on the previous install so that I could use Ninject in the WebApi package.
Then I updated the packages (because NuGet showed updates to install - even though I had updated the packages directly prior to installing Ninject).
I tried running my WebApi project but it failed on var kernel = new StandardKernel(); in NinjectWebCommon.CreateKernel() with this error:
An exception of type 'System.IO.FileNotFoundException' occurred in Ninject.dll but was not handled in user code
Additional information: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Having read several answers on here and contemplated certain relatively complex solutions I tried one more thing which I will share in the Answer in case it helps anyone else...
I removed WebApiContrib.IoC.Ninject from the WebApi project (via NuGet: Manage and then untick to remove) and then added it back.
Project runs and behaves as expected, and no updates are required after adding WebApiContrib.IoC.Ninject back in to WebApi project.
The update that NuGet identified as required overwrote/broke something that was fixed by this answer.
Add the package Microsoft.Aspnet.Mvc from Nuget.
Solved for me.
In my case, MVC4 for Framework 4.0 and Visual Studio 2017

ServiceStack Redis Client Expecting Older version of ServiceStack.Common

I just NuGetted ServiceStack.Redis 3.1.3 but as its dependencies it also gets ServiceStack.Common and ServiceStack.Text 3.1.6
Now when I build the application everything is OK.
But, when I run the application some of the Redis Client methods execute properly but some of them e.g. (RedisClient.GetAllKeys) gives throws the exception
Could not load file or assembly 'ServiceStack.Common, Version=1.0.4336.27526, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Then i removed all the dll's and nuget packgage config, and explicitly did a NuGet ServiceStack.Common -Version 3.1.3 and got it. But then when i tried to NuGet ServiceStack.Redis -Version 3.1.3 it automatically removed the 3.1.3 version of Common and downloaded the 3.1.6 version !!!
Arrrghhh, I hate over intelligent installers.
How do I fix this ?
Does the publisher of ServiceStack even know about this issue ??
Ok ! Found the Issue.
I was trying to use ServiceStack from a console application and it was configured to build in "ClientProfile" mode.
ServiceStack internally references System.Web which wasn't being accessible at runtime.
I switched the Application to Build using the full framework mode and everything works ok now.
Thanks anyways mythz !
Nope, ServiceStack was not aware of this issue. Though we'd like to know what's causing it.
I've tried a fresh install of ServiceStack.Redis and it works as expected.
To remove your dlls you need to go into NuGet package manager and finding the installed ServiceStack.Redis Package and clicking un-install. This should ensure the next install of the Project downloads it from the NuGet website and doesn't re-use your dirty dll cache.
Failing that ensure you have the latest version of NuGet and that your old NuGet caches are cleared. i.e. find and delete the NuGet /packages folder.