Sunday, July 26, 2015

Video - Custom Layout in Visual Studio 2015

Recently Microsoft has launched Visual Studio 2015 with loads of features. I have created a video for a feature called custom layouts in Visual Studio 2015. Followings are link for Youtube and Vimeo

Youtube- https://www.youtube.com/watch?v=IZ4LDZU7c_s
Vimeo- https://vimeo.com/134507008



If you  don't want to watch video then I have already written a blog post. Following is a link for that.

Custom Windows Layout in Visual studio 2015

Hope you like it. Stay tuned for more!.
Share:
Wednesday, July 22, 2015

Video - Difference between var and dynamic keyword C#

I have recently produced one video about difference between var and dynamic keyword. Please go through it and let me know how it was.

You can find complete video at following URL.

https://www.youtube.com/watch?v=FPNZ_sTfZBo



Hope you like it. Stay tuned for more!.
Share:
Sunday, July 19, 2015

SQL Server- Guest Post - Solutions for SQL Server Master Database Corruption

This blog post a Guest Post from one of my friend Priyanka Chouhan.

About Author:


Priyanka Chouhan is a technical writer in “Stellar Data Recovery “with 5 years of experience and has written several articles on SQL. She has the fine knowledge of SharePoint and SQL Server. In the spear time she loves reading and gardening.

Here is the her blog about - Solutions for SQL Server Master Database Corruption

Master database is a backbone of the SQL Server database. It is a must have database and user cannot start the SQL Server without master database. It contains the all information about server configuration. When a user installs a SQL Serverthen, it usually creates master, model, MSDB and TEMPDB system databases by default. MSDB and TEMPDB depend on the version of SQL Server database. All system databases performs the different task like: master database is used to store all system level information, TEMPDB stores the information about temporary tables and temporary stored procedures, model is worked as a template for all system created database and MSDB is used by the SQL Server Agent to schedule alerts and jobs.

Corruption in the master database is not a new thing. I will advise to all database users to take the backup of master database because without master database, SQL Server cannot be started. If corruption is high in the master database then SQL Server does not allow starting the database. In this case user can rebuild it by using command prompt or restore from the latest backup (Scroll down to see detailed information). In case of minor corruption, it might be possible that user may start the database but SQL server does not allow to access the details inside the database.

Restore from the Backup


These are the steps to restore the master database from the backup:
Start SQL Server Configuration Manager then click on the SQL Server Services.
Stop SQL Server Agent (it might connect first and prevent you to connect as a second user).
Right-click SQL Serverandthen click Properties.
Advanced tab, in the Startup Parameters box, insert –mto start the SQL Server in the Single User Mode.
Now Start SQL Server.
Start cmd.exe from start menu
Type SQLCMD on command prompt
Restore the master database using command:
RESTORE DATABASE master FROM DISK = ‘D:\MyFolder\master.bak’ WITH REPLACE
Now remove the startup parameter –m.
Start SQL Server.

This is the best way to fix master database corruption issues. If backup of corrupt master database is not available then user can easily rebuilt it by following below steps.

Rebuild System Database


Rebuild the system database means we are going to drop the re-create in their real location.

Open the command prompt and change the directories to the location of setup.exe file on the local server. Its default location in the server is C:\Program Files\Microsoft SQL Server\130\Setup Bootstrap\Release.
Enter the following command in the command prompt Setup
Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=Instance_Name /SQLSYSADMINACCOUNTS=accounts [ /SAPWD= StrongPassword ] [ /SQLCOLLATION=Collation_Name]
Once the rebuild process completes then it returns the command prompt without any message. User can view the Summary.txt log file to verify the process. The default location of theSummary.txt log file is C:\Program Files\Microsoft SQL Server\130\Setup Bootstrap\Logs.

Conclusion:

These are the methods to solve the corruption in the master database. Sometimes antivirus software can be the reason of master database corruption. So read the guidelines here to choose the antivirus https://support.microsoft.com/en-us/kb/309422/en-us



Share:
Sunday, July 5, 2015

Dependency Injection with Autofac: Keyed Registration

This will going to be a fifth post in my Dependency Injection series with Autofac. If you have not gone through all the previous post of this series then I would like to encourage you to go through it. Following is a list of blog posts.
Dependency Injection with Autofac : Getting Started
Dependency Injection with Autofac : Constructor Injection
Dependency Injection with Autofac : Module Feature
Dependency Injection with Autofac : Registration Ordering
Dependency Injection with Autofac: Named Registration

Keyed Registration:

There are multiple ways of register and resolving type in Autofac and keyed registration is one of them. Just liked named registration here you can resolve a type with a key. That key can be a valid C# object. Let’s create a sample console application for it. I have added reference of Autofac via NuGet package as did in my previous blog post. Following is a Customer class that I’ve created for the Keyed registration demo.


After creating Customer class following is a code that I’ve written for demo of Keyed Registration with Autofac.
If you see above code carefully, You can see that first I have created a object of customer as keyCustomer then I’ve register customer type with that keyCustomer Object.  After that I’ve resolved customer with that keyCustomer object and assigned few properties and then Print that customer with “PrintCustomer” object.
One thing to note that when you register type with Keyed Registration It can not be resolve without it. You can only resolve that type with same key you have registered.
Now when you run this application. You will following output as expected.

autofac-keyed-registration-output
That’s it. Hope you like it. Stay tuned for more!!.
You can find complete source code of this Autofac series on Github at - https://github.com/dotnetjalps/AutofacSamples
Share:
Friday, July 3, 2015

Dependency Injection with Autofac : Named Registration

I’m really having fun with Autofac and It is a great IOC container.  As its tag line suggest it it a addictive IOC container.  This post will be a part of Autofac series. If you have not gone through my previous blog post then I would suggest you go through it. Following is a list of blog post I’ve written for Autofac series.

Dependency Injection with Autofac : Getting Started
Dependency Injection with Autofac : Constructor Injection
Dependency Injection with Autofac : Module Feature
Dependency Injection with Autofac : Registration Ordering

Named Registration:

Named registration can be very useful when you have to create multiple object of same type with different states. Autofac provides that functionalities with Named Registration. I’m going to create a sample console application and added Autofac via Nuget package.  To demonstrate named registration I’ve created customer class like following.


Now let’s write some code to create named instance like following.
As you can see in above code, I have created a named registration with build container and then I have resolve the instance with same name which I have done registration for it. Then I populated properties of Customer and Printed that customer with “Print” function.
One thing to note here that when you register types with named instance then it can not be resolved without name. If try to resolve it it will give error.
Now when you run this application. It will print Customer as expected.

Autofac-named-registration

That’s it. Hope you like it. Stay tuned for more!.
You can find complete source code of  this Autofac series on Github at - https://github.com/dotnetjalps/AutofacSamples
Share:
Thursday, July 2, 2015

I’m Microsoft MVP again. Thank you all

Today is one of the great day in my life. I’m again an Microsoft MVP for .NET and I’m happiest person on the earth and proud of it. Today’ I got this award for fourth time. Earlier I got this award for year 2010,2011 and 2012 for Visual C#.

I would like to thank all of you readers for making my blog so much popular. Thank you my family who has sacrificed lot of time for writing blog and other community activities. Also  I would like to Mention few people without their support and encouragement it would not have been possible. So special thanks to Mahesh Dhola, Kaushal Bhavsar, Ahmedabad .NET User group , Biplab Paul  and Gandharv Rawat.

I would also like to thank my current and previous Employers who has providing excellent opportunity to be part of .NET Technology world.

11034899_10153010450113437_8068327835173356049_n

Thank you all!.  Stay tune fore more!!.
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews