I've installed VS2015 CTP, created a vNext ConsoleApplication and would like to use NodaTime.
I've added the dependency like so:
"dependencies": {
"NodaTime": "1.3.1"
},
The package gets restored, but when I try to compile the solution, a warning arises:
Type NodaTime.Instant exists in the package: NodaTime 1.3.1, Supported frameworks: .NETFramework 3.5-Client;.NETPortable-net40+sl50+win+wpa81+wp80+MonoAndroid10+MonoTouch10+xamarinios10
The type is then simply not found by the compiler, telling me:
The type or namespace name 'NodaTime' could not be found (are you missing a using directive or an assembly reference?)
Any ideas on how to fix that? Could I also just add it as an dependency of the framework that it exists for?
Most existing packages will not support ASP.NET Core 5 yet; because of the significant differences, they need to be manually updated. If you're wanting to use NodaTime, you'll either need to stick to ASP.NET 5 (not Core) or wait for Jon Skeet to release a Core version.
ASP.NET 5 (not Core) will still let you use all the new functionality, though... except not cross platform.
Related
I already added the package of Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer, but I'm still getting this error. Is anyone have an idea on how to resolve this issue?Thank you in advance.
Reference: https://www.meziantou.net/versioning-an-asp-net-core-api.htm#integration-with-ope
You haven't said which versions or runtimes you are targeting. I'm going to assume that your project is .NET Core 3.1 or newer and the language is C#. The ApiVersionDesription class is defined in Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer.dll. The following are required to resolve this error message:
Reference the Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer NuGet package
Use the corresponding namespace with using Microsoft.AspNetCore.Mvc.ApiExplorer;
You said you've already done #1 so I presume the only issue is #2. If you did not add the reference using tooling, it's worth double-checking that the NuGet package is properly referenced and the containing assembly was also added as a reference.
You also did not mention what your end goal was. 99% of the scenarios that use the API Explorer extensions for API Versioning want to wire up Swashbuckle or some other Open API/Swagger document generator. I would consider reviewing the official API Versioning Swagger Example for ASP.NET Core and cross-reference it with your configuration. It is a working end-to-end solution and should help reveal the step or steps that you're missing.
I am working in the context of a .NET Core application, windows service, and I have a compiler error telling me I've got a type that has moved assemblies. I cannot find said type and I have gone all over looking for it. So far, I have tried using a combination of dnSpy, Dotpeek, and try.dot.net to reference pertinent nuget packages or .dlls' local to my machine to find the System.Security type(s) I'm looking for. Error for the Type is as follows and afaik an assemblage with that version does not exist...anywhere!
The type name 'DirectorySecurity' could not be found in the namespace
'System.Security.AccessControl'. This type has been forwarded to
assembly 'System.IO.FileSystem.AccessControl, Version=4.0.4.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a
reference to that assembly.
Is there a way I can use external tooling to filter or find a type on my machine that the compiler is asking for? I have referenced all manner of dependencies (individually) in Visual Studio then subsequently removed them if that did not satisfy the compiler.
In any event, any help would be appreciated - thanks!
Upon further inspection of the the nuget-package the version of the specific library (and subsequent type) is .NET Standard compliant only with NET Core 2.0 and under; not 3.0 yet...so I have to downgrade the project, find a different workaround, or wait until the System.Security.AccessControl library is compliant with 3.0+.
In aspnet 5 I created a project which came with dotnet5.4 and net451. Since it's a class library I assume it does not need the runtime so uses net451 instead of dnx451 (my wild guess). But what about dotnet5.4 what exactly is that for ?
UPDATE: With this announcement, the monikers will probably change again. This answer is only scoped to the release of RC1. Any release further than RC2 won't apply here.
Basically, dnxcore50 became dotnet5.4 and dnx451 became net451.
Those were temporary to begin with and were bound to change prior to the final release.
Most of this information can be found here:
https://github.com/aspnet/Announcements/issues/98
But what about dotnet5.4 what exactly is that for ?
From Announcing ASP.NET 5 Release Candidate 1:
With this version of ASP.NET 5 templates, the “Class Library (package)” project template will target “dotnet5.4” which has binary compatibility with .NET 4.6, .NET Core 5, and Mono.
I have a previous project running Ninject 2.0 runtime version 2.0 and now I am using Ninject in a new project and using the new Ninject, ninject web.mvc version 2.2 for runtime version 4.0.
Every single time I get the error no parameterless constructor
Invalid Operation exception
An error occurred when trying to create a controller of type HomeController'. Make sure that the controller has a parameterless public constructor.
What am I missing. All the bindings are registered.
Do I need to now define interfaces for Controllers as well such as HomeController as IHomeController as I have seen in some examples, Or do I get back to using the older version
There is one version that does not show activation exceptions properly but show this exception instead. Most likely the problem is a duplicated binding.
In addition to what Remo Gloor said, you might want to check that MVC is set up to use Ninject correctly. I was doing some things manually on an older version of the MVC plugin and ended up needing to just bite the bullet and make Global extend the NinjectHttpApplication class, which I had previously been avoiding.
The error you're getting is the error you would get if MVC tries using its built-in controller factory to produce controllers. So you may want to create a custom method binding on your controller class and put a breakpoint inside to make sure it's even being invoked.
You may also want to switch to version 2.3. You can pick up the latest builds of Ninject and all its extensions here.
I have seen this issue mentioned couple of times on forums where there is no direct answer, here is the solution to the above problem, i.e., working with latest ninject
Download the latest Ninject from github.
The ninject I got for MVC2 is named as Ninject.Web.Mvc2-2.2.0.0-release-net-4.0 (runtime version 4)
Now during adding reference add Ninject.Web.Mvc.dll(check the version is same as above by right click properties in VS)
Now Add Ninject.dll from the lib folder in same parent folder (check the version as above)
Now Add CommonServiceLocator.NinjectAdapter.dll from the extensions folder in lib parent folder (check the version as above.)
The missing link in all these have been the commonserviceLocator.dll and the correct version should match. This should be tried if you are sure your bindings are correct as mine were and check to see if your project work with older version.
Thanks to everyone, and good luck :)
I've upgraded MVC3 from RC2 to RTM. We were using Ninject 2.1.0.76, but things stopped working once I upgraded. So I used the NuGet manager to get the latest Ninject, Ninject.MVC3 and Ninject.Web.Mvc libraries (2.1.0.91, 1.0.0.0 and 2.1.0.39 respectively). Now, it creates an AppStart_NinjectMVC3 file.
I removed NinjectHttpApplication from my global.asax and made it back into a regular HttpApplication. When I tried to build, I get;
"Exception has been thrown by the target of an invocation"
Looking further, if I disable the following line;
DependencyResolver.SetResolver(new NinjectServiceLocator(kernel));
The build goes through. But I'm pretty sure I don't want to do this.
Any ideas?
----- UPDATE ---------
I created a new MVC3 project, added the reference to Ninject.MVC3 and this builds and runs fine. I compared web.config, don't see any differences that relate to Ninject or MVC in the two. A fresh project doesn't add the Ninject.Web.Mvc library, so I removed it and commented out all code relating to that, and still, the error occurs.
Since ASP.NET MVC 3 Beta the IServiceLocator interface is replaced by IDependencyResolver. I'm not sure Ninject.MVC3 already has a release where they have implemented this interface.
Judging from the line DependencyResolver.SetResolver(new NinjectServiceLocator(kernel)) it appears they have not.
Here's a simple implementation of this interface for Ninject.
UPDATE: The Ninject.Web.Mvc library has a NinjectDependencyResolver class that extends from the IDependencyResolver interface. I think you should use this one (I do and everything works fine).
Download the dlls from here
https://github.com/ninject/ninject/archives/master
https://github.com/ninject/ninject.web.mvc/archives/master
Further more do not use Ninject.MVC3 all you need ist Ninject.Web.Mvc
I also have an article documenting same here