I get the following error when trying to use an X509Certificate2UI in VS Code:
The type or namespace name 'X509Certificate2UI' does not exist in the namespace 'System.Security.Cryptography.X509Certificates' (are you missing an assembly reference?) [netcoreapp1.1]
I've found a few sites that indicate the solution is to add the system.security.dll assembly, but these responses don't seem to be catered toward VS Code. I've already added the X509Certificates dependency to the project.json file, which doesn't seem to do me much good:
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"System.Security.Cryptography.X509Certificates": "4.3.0" //"4.3.0-*"
},
"imports": "dnxcore50"
}
Any help would be greatly appreciated :)
-Nate
X509Certificate2UI is not part of .NET Core. It's a Windows-only class, and a UI class at that, and it was not carried over.
You will have to move to a UI-free solution, or cross-compile to target .NET Framework.
Related
I get this warning building my asp.net core project on teamcity, and also appears as a warning in visual studios:
Dependency specified was Foo.Client >= 1.0.0-* but ended up with Foo.Client 1.0.25523.
I don't understand why this doesn't match. I can't seem to find any documentation on how to make these wildcard strings.
1.0.25523 is a copy a replace operation I do on my build server to reflect the build number. It's not something I'd like to directly reference, I'm just confused as to why my 1.0.0-* isn't accepting something that looks just to differ by patch version.
My package config looks something like this:
{
"version": "1.0.0-*",
"dependencies": {
"Foo.Bar.Client": "1.0.0-*",
},
"frameworks": {
"net46": {
"dependencies": {
"Foo": {
"target": "project"
}
},
"frameworkAssemblies": {
}
}
}
}
And then the substitution is made here and in the Foo.Bar.Client project.json to change "version": "1.0.0-*" to "version": "1.0.25523"
There should be a *.nuspec file for your project, which will have the information about which package version you're using. From your error message, it seems that the package version in this file is 1.0.0 whereas you'll want to change this to 1.0.25523 I think.
You can also check here for some more information.
I have created a class library project in which I have defined my Models, DbContext, connectionstring and etc. However , I am not able to add migration using the command below
Command
dotnet ef migration add initial
I am getting the error below
Error
Could not invoke this command on the startup project 'Alan.Pois.Data'. This version of the Entity Framework Core .NET Command Line Tools does not support commands on class library projects in ASP.NET Core and .NET Core applications.
Below is the project.json
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.1",
"Microsoft.EntityFrameworkCore.Design": { "version": "1.1.0", "type" : "build" },
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
"CommonServiceLocator": "1.3.0"
},
"frameworks": {
"net461": {
}
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools.DotNet": {
"version": "1.1.0-preview4"
}
}
}
IS there anything missing ?
regards,
Alan
I have my context, models and repositories in a class library. My migrations are kept in my web project for the tooling to work (the workaround that I thought was best for the same situation you are experiencing) with a simple configuration call in my EF Core registration. Not sure if this is an option for you...
There are other ways around this, like configuring your class library as an application, and, I realize you'd still need to reference EF packages in two projects (the web app and class library in my case) with the way I'm doing it. I haven't done the "configure your class library as an app" because it just feels like punching something into submission.
Here's EF setup from my Startup.cs:
services.AddDbContext<MyContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MyConnectionString"), b => b.MigrationsAssembly("MyStartupProject")));
I have made an empty asp.net web app with the new dnu/dnx/vscode combo of utilities.
It's working fine until I try to add 3.party libraries.
I have tried to add MongoDB with the following cmd:
dnu install MongoDb.Driver
dnu restore
This adds the mongodb dependency to my project.json file:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
"Kestrel": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"MongoDb.Driver": "2.0.0"
},
...
but when I try to actually reference mongo, things fail:
using MongoDB.Bson;
VSCode gives me intellisense to add this namespace, but it adds a red squiggle under MongoDB and a green one under Bson.
when I try to build the project with
dnu build
it fails with the message
C:\source\.....cs(2,7): error CS0246: The type or namespace name 'MongoDB' could not be found (are you missing a using directive or an assembly reference?)
What am I missing here?
My project.json file is totally untouched - except for the added mongo dependency:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta4",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta4",
"Kestrel": "1.0.0-beta4",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"MongoDb.Driver": "2.0.0"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5001"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {}
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
Check what frameworks are listed in your project.json file and if you need an extra or different dependency for the coreclr-ish framework.
You may have to reload the editor as well when adding new dependencies. Command palette -> Reload Window
Answer on twitter regarding this issue
Edit: Probably not helping you, but this thread may be related. Seems like the MongoDB driver package is hard to get running with som versions of ASP.NET.
That is because MongoDb c# drive doesn't support CoreCLR yet. See this discussion. Simply remove the "dnxcore50": {} in your project.json and it will work.
Previously (Beta5) I got the same error doesn't give the meaning. Now I realize now in ASP.NET 5 Beta8 produce the meaningful error:
The dependency MongoDB.Driver.Core 2.1.0 in project does not support framework DNXCore,Version=v5.0.
I am trying to include Google Analytics API package in my MVC 6 application. I've tried to include all the dependencies or to let it install trough NuGet Package Manager. In either case, when i build the solution, I get an error: Error CS0246 The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?) ProjectName.ASP.NET Core 5.0
Any idea what dependencies I need to include for it to build in ASP.Net Core 5.0?
Here is what i have in my project.json file:
"dependencies": {
...
"Microsoft.Net.Http": "2.2.28.0",
"Microsoft.Bcl": "1.1.9.0",
"Microsoft.Bcl.Build": "1.0.21.0",
"Microsoft.Bcl.Async": "1.0.168.0",
"Google.Apis.Analytics.v3": "1.9.0.1100"
},
...
"frameworks": {
"aspnet50": {
"dependencies": {
}
},
"aspnetcore50": {
"dependencies": {
"Newtonsoft.Json": "6.0.8.0"
}
}
},
Similar issue to the one described here: Problems with RavenDB.Client reference in asp.net 5.0 project.json
Adapting my answer from there:
The problem is that you referencing Google.Apis.Analytics.v3 in the top level dependencies node in project.json. That means that those dependencies are applicable to both Desktop CLR (aspnet50) and CoreCLR (aspnetcore50).
When you build an ASPNET 5 project, all configurations are built, not just the "active" one. Mostly sure Google.Apis.Analytics.v3 works only with the Desktop CLR so move it under a dependencies node under that configuration.
"dependencies": {
....
},
"frameworks": {
"aspnet50": {
"dependencies" : {
"Google.Apis.Analytics.v3": "1.9.0.1100"
}
},
"aspnetcore50": {}
}
Then you might have to either use some conditional blocks in your code (#if ASPNET50) or remove CoreCLR all together.
Then you might have to either use some conditional blocks in your code (#if ASPNET50) or remove CoreCLR all together.
I am currently using ngboilerplate from: https://github.com/ngbp/ngbp
I want to include the 'ui.bootstrap.datepicker' from UI-Bootstrap (Twitter Bootstrap written natively in AngularJS). The problem is that this doesn't seem to be included in the latest version of ngboilerplate. Does anyone know how I can add this accordingly to the style of ngboilerplate.
This means that other developers can load it as a dependency with bower install.
After trying a couple of things it seems to be quite easy actually. I'll just answer this question in case someone else has the same problem.
I needed to install a new version of UI-Bootstrap. This can be done with bower by executing (on windows):
bower install angular-bootstrap
But this will give you a whole lot of other problems with dependencies.
To resolve this I use this bower.json:
{
"name": "Your-app",
"version": "0.3.1",
"devDependencies": {
"angular": "1.2.4",
"angular-mocks": "1.2.4",
"bootstrap": "3.0.3",
"angular-bootstrap": "0.10.0",
"angular-ui-utils": "0.0.3"
},
"dependencies": {
"angular-ui-router": "0.2.8-bowratic-tedium"
},
"resolutions": {
}
}
Another problem I had was that the LESS code for bootstrap isn't up to date. Instead I just included the bootstrap.css in my main.less file.