Sunday, April 26, 2009

Solve "Access is Denied" error when opening .msc files

Today I got a very annoying error.


I tried to open services.msc and got the error:



The beauty of this error was the I was able to open the it through : My Computer :: Manage :: Services and Applications :: Services.

I googled through the error and found a lot of replies : Some of them suggesting some software restriction policy of the user not being Administrator and so on.
All did not apply to me as my computer is me personal home computer and not part of any domain and I was able to open it till a few days back (or the last time I openend it) and nothing changed in between.
So whats the issue. I am a Admin. I navigated to C:\Windows\System32 and checked the permissions for the services.msc file and as Admin I had Full Control over the file.

Then I found something special : I was able to execute "eventvwr" but not "eventvwr.msc" which gave the Access is Denied Error.

That was the Euraka moment. It had something to do the MS Management Control or "mmc.exe" which is used to open all these ".msc" files. I openend "mmc.exe" and loaded the snap-in "Services" and it loaded up fine.

Then the solution was simple :: The extension ".msc" has somehow lost the information that it needs to be "openend with" mmc.exe

So I did a right click on "services.msc" and selected "Open with". In the window I browsed to "C:\Windows\System32\mmc.exe" and phew it worked.
I checked "services.msc", "eventvwr.msc", "compmgmt.msc" and all worked fine.

Hope it works for you too :)

Friday, April 10, 2009

Unit Testing, Code Analysis and Code Metrics in VS.NET 2008


In .NET we prefer to use VS .NET to do unit testing.Both VS 2005 and VS 2008 Team Editions support unit testing.
Way to do :

  1. Add a unit test project to your solution.
    Navigate to the method that needs to be tested. Do a right click : Create Unit Test on the method.



  • In the Wizard provided:Click on Setting. As of now MS does not support prepending Namespace before the class. This is of great value to us as need the namespace to distinguish similar class names in multiple namespaces. So we manual prepend the namespace i.e. 'Manager_' in the current case.



  • A dummy test case gets created:Modify the expected value to match whats expected. We can add more 'Asserts' to improve the test case.




  • To execute the test case, do a right click on the test case and select 'Run Tests':




  • The test will be executed and the run status displayer. We are re-run the test case or we can debug it with the appropriate buttons selected on the top:




  • To view the code coverage results, right click on the test case and select 'Code Coverage Results'.




  • The result will contain all the project which got invoked to make the test run:




  • Details of the method tested:






  • Similarly we can do a Code Analysis based on Coding Standards and generate Metrics

    Coding Standards:




    Coding Metrics:




    • Wednesday, April 8, 2009

      My Election Consituency

      I belong to Bokaro Steel City which is part of the Dhanbad Constituency.
      I currently stay at Koramanagla which belongs to the Bangalore South Constituency.