I have a WCF service that acts on domain classes in my Core site. Since Core doesn't produce a dll I can't include a reference to them in my service project. I've resorted to declaring them in both projects, but that is a maintenance problem. The other option I can think of is a separate dll for just the shard classes that both would reference, but some of them are EF objects, so that becomes a problem too. Is there a way of referencing classes contained in a Core project from another project in the solution?
Referencing Classes in Core Project from WCF Service Project
Core CLI confusion?
This will probably be the 1st of many questions. I'm asking about the .net cli as it relates to asp.net core 1.0. I was keeping up until version (RC2) where i think the .net CLI was introduced and DNX, DNU, & DNVM where killed. To be honest i loved the way DNX, DNU, & DNVM worked. I'm not sure i like the decision to move to the .net cli but it "might" be my lack of understanding which i'm trying to clear up. One of the things i was REALLY looking forward to was the ability to use the newest/greatest version of .net without asking my admin to install the newest .net framework on the server which would force every app on that server to use the same framework.
I've watch a variety of videos on the .net CLI. The latest one with Scott Hunter: https://channel9.msdn.com/Events/DevDays/DevDays-Latam-2016/NET-CLI
From my understanding .net cli is kind of like the .net framework but a mini .net framework that will be shared on the machine that will be shared for many apps. So if i want to use the newest & greatest version of .net i again have to get the sysadmin to
install the latest version of the .net cli on the server right? I can't just bundle it with my app? If this is true i think this is definitely a step backwards rather than a step forwards. During the video after created an app with 'dotnet new' Scott makes
a change to the project.json:
{"version": "1.0.0-*","buildOptions": {"debugType": "portable","emitEntryPoint": true },"dependencies": {},"frameworks": {"netcoreapp1.0": {"dependencies": {"Microsoft.NETCore.App": { /*"type": "platform",*/"version": "1.0.0" } },"imports": "dnxcore50","runtimes": {"win10-x64": {} } } } }
I got excited because when he did a publish he got some dlls in the directory which seemed to be all the framework dlls. But when i attempted to do the same:
I commented out exactly what he commented out "type" and added the runtimes tag but when i try to build i get the following error:
Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'win10-
x64, win81-x64, win8-x64, win7-x64'. Possible causes:
1. The project has not been restored or restore failed - run `dotnet restore`
2. The project does not list one of 'win10-x64, win81-x64, win8-x64, win7-x64' in the 'runtimes' section.
3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.
As you can see it didn't work even though i added the runtimes flag.
So are my hopes crushed? Will we have to get sysadmins to install the newest version of the dotnet cli on the server and we can't bundle the framework with our app? Yes i understand the dotnetcli will have the older versions of the .net standard library too but that is still going to require a sysadmin to install it on the server. With the DNVM it was so easy to update it and also to add new version of the framework. I hope i'm just confused and don't quite understand how the dotnet cli works and everything is still possible.
How to automate the task in Task Scheduler if it is in remote machine?
I am looking for a way through which
1. I can check the status of the task in Task Scheduler which is in Remote machine.
2. Also if the task is not running then instead of running it manually I want to automate it so that with a button click it will start running so as to avoid login to that remote machine and run it manually.
Is this possible to do? Please help me with your suggestions and answers? Is it possible to do this using any API in ASP.Net?
Nuget for ClientAssertionCertificate class in asp.net core to connect to AAD throught ADAL
Hi ,
We are trying to connect to AAD to get access token/jwt token using Certificate instead of using Client Secret in Asp.Net Core application . But Microsoft.IdentityModel.Clients.ActiveDirectory nuget ( version: 3.10.305231913 ) has only IClientAssertionCertificate interface . There is no concrete method for this class. Do we have any nuget package for this interface implementation?
Thanks
How to isolate dynamic code / assemblies without appdomain
With .NET 4.5 I created an extensible web application. With executes at run-time certified code from third parties.
For this, I use app domains and inter-process communication.
Now I saw that a lot of technologies I used for this aren't any more supported in .NET core
like:
- AppDomains
- Remoting
- BinarySerzializers
For most of them, there are obvious solutions(Protobuf, rest...). But the remove of AppDomains is a tough thing.
If I understand it right I should use processes. But if my application has about hundreds or thounds Extensions (multiple customers) this would mean I would also have hunded and thounds of processes.
But I don't feel very comfortable with either one. In the one way, I would end up with hundreds of processes. And if I group I could still get influences between them.
So what would be the right way to choose?
I Also posted on SO (if someone is hunting points) http://stackoverflow.com/questions/38048549/best-practice-how-to-isolate-dynamic-code-assemblies-with-net-core
How to Pack / Reference "old" assemblies in 1.0 Tooling
I've heard that the tooling with ASP Core will change one more time (deprecating the project.json and so on)
Are there any informations about the planned way to reference "old" 4.* assemblies in core projects?
in RC 2 I wrapped them in nuget packages to a defined folder and made the folder accessible through global.json.
Is it likely that this will be a similar way in the 1.0 Tooling ? Or may be file references will be introduced again?
Any tessources pointing on an answer to this?
User.Identity.Name Outside a Controller
I am trying to get the this
User.Identity.Name,
I can get it in the controllers, but I would like to know if it can be done outside a controller on a simple class, Somethikng like this
Public string GetUserEmail()
{
var userEmail = User.Identity.Name
}
How to test code in Asp.net core project, in controller class in a controller folder
I have an ASP.net core project, using controllers and models, I have a ValidatePromoCodeApi class ,
[HttpGet]
[Route("/ValidatePromoCode")]
// [SwaggerOperation("ValidatePromoCodeGet")]
// [SwaggerResponse(200, type: typeof(PromoCodeResponse))]
public IActionResult ValidatePromoCodeGet([FromQuery]string promocode, [FromQuery]double? staylength, [FromQuery]double? orderAmount)
{
SqlConnection sqlConn = new SqlConnection("server=ROHIT-LAPTOP\\SQLEXPRESS;database=UseTest;uid=rohit;password=111222Rt;");
string sql = "spReadParam";
SqlCommand sqlCmd = new SqlCommand(sql, sqlConn);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.AddWithValue("@Param", "Rohit");
SqlParameter outPutParam = new SqlParameter();
outPutParam.ParameterName = "@ParamOutput";
outPutParam.SqlDbType = System.Data.SqlDbType.VarChar;
outPutParam.Direction = System.Data.ParameterDirection.Output;
sqlCmd.Parameters.Add(outPutParam);
sqlConn.Open();
sqlCmd.CommandText = sql;
sqlCmd.ExecuteNonQuery();
sqlConn.Close();
string Parameter = outPutParam.Value.ToString();
return new ObjectResult(theResp);
}
Error in case of up-dating of packets Nuget.
Hi!
PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git C:\Program Files\dotnet\dotnet.exe restore "C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\.vs\restore.dg" log : Restoring packages for C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.json... log : Restoring packages for tool 'Microsoft.AspNetCore.Razor.Tools' in C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.json... log : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.json... log : Restoring packages for tool 'Microsoft.EntityFrameworkCore.Tools' in C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.json... log : Restoring packages for tool 'Microsoft.Extensions.SecretManager.Tools' in C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.json... log : Restoring packages for tool 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' in C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.json... error: Version conflict detected for Microsoft.CodeAnalysis.Common. error: ProjectX (>= 1.0.0) -> Microsoft.AspNetCore.Mvc (>= 1.0.0) -> Microsoft.AspNetCore.Mvc.Razor (>= 1.0.0) -> Microsoft.CodeAnalysis.CSharp (>= 1.3.0) -> Microsoft.CodeAnalysis.Common (= 1.3.0) error: ProjectX (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Tools (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Utils (>= 1.0.0-preview1-final) -> Microsoft.CodeAnalysis.CSharp.Workspaces (>= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Workspaces.Common (= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Common (= 1.3.0-beta1-20160429-01). log : Writing lock file to disk. Path: C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\project.lock.json log : C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\ProjectX.xproj log : Restore failed in 13039ms. Errors in C:\Users\dbaev\Documents\Visual Studio 2015\Projects\ASP.NET Core\ProjectX\src\ProjectX\ProjectX.xproj Version conflict detected for Microsoft.CodeAnalysis.Common. ProjectX (>= 1.0.0) -> Microsoft.AspNetCore.Mvc (>= 1.0.0) -> Microsoft.AspNetCore.Mvc.Razor (>= 1.0.0) -> Microsoft.CodeAnalysis.CSharp (>= 1.3.0) -> Microsoft.CodeAnalysis.Common (= 1.3.0) ProjectX (>= 1.0.0) -> Microsoft.VisualStudio.Web.CodeGeneration.Tools (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Core (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Templating (>= 1.0.0-preview1-final) -> Microsoft.VisualStudio.Web.CodeGeneration.Utils (>= 1.0.0-preview1-final) -> Microsoft.CodeAnalysis.CSharp.Workspaces (>= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Workspaces.Common (= 1.3.0-beta1-20160429-01) -> Microsoft.CodeAnalysis.Common (= 1.3.0-beta1-20160429-01).
How to correct it?
Thanks you!
What is [FromServices]
I saw something somewhere like
[FromServices] public Data Data { get; set; }
I can't find the definition of it.
There were no solutions found.
So i just created a .net core app on my mac and pushed it to a git repository on Visual studio.com. Great worked just fine the code is there.
Then i opened Visual Studio on my PC and connected to the git repo and cloned it. Great, now its connected but no files are in solution explorer? This is not working well? I am missing something? I cant open the solution because there is no solution.
Version of Dot Net Framework
I do have framework 4.5 installed on my machine but I see only 4.0 and 2.0 showing up in the dropdown when I go to "Edit Application Pool"
What do I need to do to fix it so I can select 4.5? I am trying to install DotNetNuke which requires app pool running under 4.5
Code first approach for SQLite data source
Hi,
I have some problem while mapping foreign key in Code first approach for SQLite.
Table:
CREATE TABLE Employees ( [EmployeeId] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, [FirstName] NVARCHAR(20) NOT NULL, [ReportsTo] INTEGER, [Phone] NVARCHAR(24), FOREIGN KEY ([ReportsTo]) REFERENCES "employees" ([EmployeeId]) ON DELETE NO ACTION ON UPDATE NO ACTION )
Class Mapping
public class Employees { [Key] public int EmployeeId { get; set; } public string FirstName { get; set; } public int ReportsTo { get; set; } // [ForeignKey("EmployeeId")] public string Phone { get; set; } }
Error : Object reference not set to an instance of an object.
If I remove ReportTo property mapping in my Employees class it works fine. how to do ForeignKey mapping?
Thanks,
Connecting to databse? [EF Core] [npgsql/PostgreSQL] [Identity]
Hello all,
I've created a project through the wizard with the template ASP.NET Core Web Application, authentication: Individual user account.
I then installed Npgsql.EntityFrameworkCore.PostgreSQL.
Now im obviously trying to connect these. The PostgreSQL server is fine, and VS can connect to it through Server Explorer with the DevArt dotConnect I installed earlier.
By default Identity?/Entitity? uses MSSQL by default.
I couldn't find the answer on the internet, so I started to try things, and after awhile became very puzzled if I'm on the right track. Thanks!
I updated the the default connection string in appsettings.json:
"ConnectionStrings": {"DefaultConnection": "Server=localhost;Port=5432;User Id=postgres;Password=********;Database=SamenApp;Persist Security Info=True" },
and changed Startup.cs to load Npgsql:
public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); services.AddMvc(); // Add application services. services.AddTransient<IEmailSender, AuthMessageSender>(); services.AddTransient<ISmsSender, AuthMessageSender>(); }
When a user connects I get a exception at base(options)
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } ...
An exception of type 'System.TypeLoadException' occurred in Microsoft.EntityFrameworkCore.dll but was not handled in user code
Additional information: Could not load type 'Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionExtensions' from assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Azure Storage Nuget Package
Does anyone know what Nuget package to download for access Azure Storage from Asp.Net Core?
"Connected services" is not going to work for me:
1.) It installs a bunch of packages that are incompatible with .NetStandard v 1.6
2.) I need something more flexible, where I can dynamically pass in the Azure Storage account credentials to my blob manager class.
Any ideas???
How to call a REST Service from Asp.net Core?
HttpWebRequest seems to be missing.
How do we call a rest web service in Asp.Net Core?
How should I do to make my DI register code more clean?
I am using the default service container in asp.net core 1.0 rc2. In my project, I need to register many services, like code below.
//for all type not inherit Asset
services.AddSingleton(typeof(IProvider<>), typeof(Provider<>)); //for those :Asset
services.AddSingleton<IProvider<Asset>, AssetProvider<Asset>>();
services.AddSingleton<IProvider<BastionHostAsset>, AssetProvider<BastionHostAsset>>();
services.AddSingleton<IProvider<CloudAccountAsset>, AssetProvider<CloudAccountAsset>>();
services.AddSingleton<IProvider<DeviceAsset>, AssetProvider<DeviceAsset>>();
services.AddSingleton<IProvider<LoadBalanceAsset>, AssetProvider<LoadBalanceAsset>>();
services.AddSingleton<IProvider<VMAsset>, AssetProvider<VMAsset>>();
services.AddSingleton<IProvider<StoreAllocAsset>, AssetProvider<StoreAllocAsset>>();
Unlike all the generic types register at the first line code, I have to register every type which inherits Asset line by line, boring work.
Can I improve the code more clean? I wish there is one line code to registerall the providers for types inheriting Asset, may be like below:
services.AddSingleton<IProvider<T>,AssetProvider<T>> where T: Asset
How should I improve my code ?
Thanks.
Redirecting one project to another project in same solution Asp.net-How to specify path
I Have Three projects in a same solution Project 1,Project 2 and Project 3. Project 3 contains single login page for both the Application (Single Database) once i click login button in project 3 it has to redirect to Project 1 Dashboard.aspx page can anyone tell me that how to redirect from one project to another project in same solution. how to specify that folder paths in application.
how to change /Seach?name={string} to /Search/{string} during get method?
<form asp-controller="Product" asp-action="Search" method="get" class="navbar-form navbar-left" role="search"><div class="input-group"><input type="text" name="name" class="form-control" placeholder="Search" /><span class="input-group-btn"><button type="submit" class="btn btn-default">Search</button></span></div></form>
here is my form, how to change /Seach?name={string} to /Search/{string} during get method
The project doesn't know how to run the profile IIS Express
Hi,
after switching to RC2 (following these guidelines: Core RC1-to-RC2) I can not start the project, but the message:
"The project doesn't know how to run the profile IIS Express"
Any hints?
Thanks Bo