Skip to main content

Posts

Error: Icon file is not set to be published...

Today while working on one of the application that was for ClickOnce deployment I faced a small issue which took almost my half an hour. My task was to associate a default icon to my application. So, in order to do this, I went to my project properties and simply set the icon as shown below: As you can see in above screenshot, it is showing an error icon which states: 'Icon file is not set to be published with the application, or is not part of the required download group' Then I build my application and land up with below error message which was more clear: After hitting my head for many minutes, I thought, let's check out what is this 'download group'. On surfing net, I got the clue that download group is nothing but a collection of files which are going to be part of our publish activity. So, I quickly opened Application Files dialog using Project properties >> Publish. The Application Files dialog looks like:

Back to blogging

Hey friends, I’m back to my blogging world after a gap of few months. Yes, you are right. I’m alive. Actually I was busy with motherhood J Last night, I was scared to look at my blog, fearing all the followers have given up on me. Trust me, this is very-very scary feeling. Although it’s been not so long since I become a blogger but a fear of losing followers, who actually take time to read my posts is something which I can’t express. Hope you are reading this. After a long break, it is bit difficult to get the same momentum. But I’ll try to make it up. So, stay tuned and keep reading. H appy learning!!!

Reading version information from project.json

As of now, many of you are aware about the information stored in project.json file in ASP.NET Core 1.0. My this blog post will tell, how to retrieve the version number from project.json file. Below is the screenshot of my json file: And below is the code to get the version number: public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { // Reading project.json file var projConfig = new ConfigurationBuilder ().AddJsonFile( "project.json" ).Build(); //app version number var appVersion = projConfig[ "version" ]; // SQL Server version number var sqlServerVersion = projConfig[ "dependencies:EntityFramework.MicrosoftSqlServer" ]; } Hope this post was helpful.

Application State in ASP.NET Core 1.0

Introduction to Application State Application state provides a way to store in-memory data, which are smaller in size. It includes both global and user-specific data. Such data can be used across application and can be used by all users. Prior to ASP.NET Core 1.0 also there were Application and Session state options available to store such sort of data. Ways of managing Application State? Now question is, which state storage provider is to be used and when? It is influenced by variety of factors: Size of data Format of data Duration to persist data Sensitivity of data, etc. Based on your answers, Application State can be managed in variety of ways like: HTTPContext Cookies Session Querystring and Post Cache Other options (EF, Azure Table Storage, etc.) As part of ASP.NET Core 1.0 release, there is change in HTTPContext object. Hence I’ll emphasis on that. HTTPContext: Items collection of HTTPContext is used to store data which is required onl

Consuming Services in ASP.NET Core MVC View

In continuation to my previous post entitled 'Consuming Services in ASP.NET Core Controller' on injecting services in controller, this time I'm writing on how to inject services directly in MVC View. In order to achieve this, a new keyword @inject is used. Here I'm not writing entire code again as it can be referred from my previous article. Let's register the service in ConfigureServices method as: public void ConfigureServices( IServiceCollection services) { ... ... services.AddTransient<IGUIDService,GUIDService>(); } Next is to inject service inside a View as: @inject IGUIDService guidService Now service is injected and available for use. Let's quickly use it: @ using CustomTagHelper.Services; @ inject IGUIDService guidService <p>@guidService.GenerateGUID()</p> Run your application and you will be able to see the required output as: Hope you enjoyed learnin

Consuming Services in ASP.NET Core MVC Controller

Another interesting feature of ASP.NET Core is service consumption using Dependency Injection. I already provided the overview of Dependency Injection in my earlier articles. Moving further, in this article we will see how one can inject and consume services to controller using dependency injection. In ASP.NET, you can access services at any stage of your HTTP pipeline through dependency injection. By default, it provides Constructor injection, but it can easily be replaced by any other container of your choice. Before moving ahead, one point is very important to understand and that is lifetime of services. ASP.NET Core allows you to configure four different lifetimes for your services. Transient - Created on every request Scoped - Created once per request Singleton - Created first time when they are requested Instance - Created in ConfigureServices method and behaves like a Singleton To understand the service consumption in easier way, we will create a sample applica

Tag Helpers in ASP.NET Core 1.0

Exclusive Amazon Deals This article is for those who would like to use Tag Helpers over old Razor/HTML helpers. Tag Helpers, another new feature of ASP.NET Core. Let’s quickly have a look at it. What are Tag Helpers? As per ASP.NET documentation:                     " Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files ". Tag Helpers are somewhat similar to HTML Helpers/Razor Helpers introduced in previous version of ASP.NET MVC but those helpers were not that easy to understand for web designers because of inline C# method calls. As web designers are more inclined towards HTML, a simpler and comfortable approach was required. Fortunately, ASP.NET Core 1.0 provided that. Now one need not to use HTML Helpers to build cshtml forms. Means when you had to write this: Now you can write this: As you can see a bove format is very easy to understand as it is purely a HTML syntax. How Tag Helpers wor