Friday 27 December 2013

Applying Observer Design pattern using C#

Design patterns are solutions to commonly recurring problems incurred during software development. Observer is one of the most popular design problem and is also known as publisher/subscriber pattern. If you want to see how this pattern can be applied in real life scenario then please read my article.
Real Time Stock Feed Dashboard (Applying Observer Design pattern using WPF in c# )


Tuesday 17 December 2013

Office Development Using VSTO and C#

If you are interested in doing Microsoft Office Development and would like to leverage the power of latest .NET framework features such as Entity Framework and C# language features such as LINQ and Lambda Expressions then the below link to my article may be of interest to you. I request you read this article and let me know if you need any further help or have any queries. Enjoy reading!
Implementing Custom Action Pane and Custom Ribbon For Excel 2010 using VSTO and C#

Thursday 24 January 2013

Can't create Database. Permission denied on master database.

Recently I was working  on ASP.NET MVC 4.0 Project using Visual studio 2012 and trying entity framework code first. Entity framework Code First approach automatically creates the  database schema and tables based on model defined in the code.
After doing build and running my sample project I was getting an exception with the message.
"Can't create Database. Permission denied on master database!". 
I was surprised as I was administrator on my laptop and it took me some time to figure out what's happening. Finally I manage to resolve this issue.  Here is the detailed explanation
1.With Visual studio 2012 SQL-Server 2012 LocalDB Express is used for development.
2.On my laptop I had one more instance of SQL-Server express.  Entity framework was looking for this instance and I didn't  have sysadmin rights on this instance and hence was giving the issue. Also I had forgotten password for sa user and couldn't give rights to my account.
3. So I stopped this instance and disabled this service. So that I can use LocalDB express.
4. Last thing was telling the entity framework to check for LocalDB and I found the setting to be done in web.config. The setting is given below.

.

<entityFramework>
    <defaultConnectionFactory
        type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, 
            EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
5. I was then ready to recompile and test and it worked fine.
I hope you will find this useful! as I spent couple of hours to investigate what's happening.