Ninject MVC3 leads to "cannot find file Mvc.sitemap" - ninject

I am trying to use Ninject on a Web project. In Visual Studio I ran
Install-Package Ninject.MVC3
But now when I run the project I get the error
Could not find file '<path>\Mvc.sitemap'
What is this Mvc.sitemap file?

Managed to resolve the problem by installing:
Install-Package MvcSiteMapProvider.MVC5
Still don't quite understand why Ninject depends on SiteMap.

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.

NinjectWebCommon.cs file is not adding after install ninject nuget package

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.

'MySql.Data' already has a dependency defined for 'System.Text.Encoding.CodePages' [duplicate]

I'm trying to add AutoMapper as a dependency to a project using NuGet on Visual Studio Premium 2012, but it fails.
It says:
Operation failed
'AutoMapper' already has a dependency defined for
'Microsoft.CSharp'.
I'm able to add other dependencies.
I'm using the last version of the package manager for VS 2012:
NuGet Package Manager 2.8.60318.667
Any ideas what should I check?
The problem is that your NuGet Package Manager is too old. You need NuGet 2.12 since this supports the newer .NETStandard frameworks that the AutoMapper 5.0.1 NuGet package is using.
The AutoMapper has a group dependency which specifies a target framework of .NETStandard. Since your version of NuGet Package Manager is too old it does not recognise this target framework and converts it to an Unknown target framework and you end up with duplicate frameworks since there .NETStandard is used a few times in that NuGet package. This causes the error:
'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'
Unfortunately NuGet 2.12 is not available for Visual Studio 2012 but is available for Visual Studio 2013.
So either you need to update to Visual Studio 2013 or above, or you will have to use the older AutoMapper NuGet package which does not support .NETStandard.
Seems to be a problem with the current version of automapper:
AutoMapper 5.0.0 Tuesday, June 28, 2016
I tried with the previous version and it works:
PM> Install-Package AutoMapper -Verbose
Install-Package : 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp'.
At line:1 char:16
+ Install-Package <<<< AutoMapper -Verbose
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
PM> Install-Package AutoMapper -Version 4.2.1
Installing 'AutoMapper 4.2.1'.
Successfully installed 'AutoMapper 4.2.1'.
So, if you can't update NuGet Package Manager, the answer is:
PM> Install-Package AutoMapper -Version 4.2.1
I ended up needing to update NuGet.exe that was included in the solution to be able to build NuGet packages by running:
nuget.exe update -self
I had the same issue on VS2013. I had to update to VS2013 Update 5 and get the latest nuget distro for VS2013 at
https://dist.nuget.org/visualstudio-2013-vsix/v2.12.0/NuGet.Tools.vsix
Once that was done, I rebooted Visual Studio. After that I was able to use the Automapper 5.0.2 package
Go to Visual Studio > Tools > Extension and Updates
Find Updates in left accordion menu, Go to Visual Studio Gallery.
You will find a update for Nuget.
Update the nuget package and try installing or builing the project.
Thanks,
GT
An other workaround if you're stuck with VS2012 and the old Nuget version:
Find the Cache folder of VS 2012's Nuget Package Manager (with Tools - Options - Nuget Package Manager)
Open AutoMapper.5.x.x.nupkg with your favorite Zip Tool
Modify the file AutoMapper.nuspec - I simply deleted all dependencies except .NETFramework4.5
Add the cache folder as a Nuget source (also in Tools - Options - Nuget Package Manager)
Install Automapper either with the console or the GUI but make sure to choose first the newly added cache folder as package source.
Of course, the next version of Automapper probably needs to be adapted, too, in order to install it.
This looks like a mismatch between the .NET version used by the Automapper package and your project. Can you confirm the .NET version that your project is using?
Automapper 6.0.2 - nuget 2.8.8 gives this error. Needed to update to 3.4.4 to get this working.
Removed both CSharp and AutoMapper. Installed CSharp (4.0.0.0) first and then added Automapper (6.1.1.0). This resolved the problem for me.
I observed this exact problem when opening a project with Visual Studio 2010.
After opening with VS2017, I was able to install AutoMapper without any error.

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