Wednesday, September 9, 2009

Install Microsoft.mshtml on client machines using ClickOnce

I had recently published an application using ClickOnce which used MS Office Primary Interop Assemblies. When a user tried to install it, he got an error :

MSHTML Error

I was surprise at first as I was not at all using Microsoft.mshtml in my application. As it turned out, the PIA's refer to this dll internally. As I have Visual Studion installed in my workstation, the Microsoft.mshtml had got added to my GAC and the appliaction worked fine on my workstation. People who have not installed Visual Studio or .NET Framework SDK dont have it in there GAC hence the error. Now that I found the problem, I had to find a solution.

Tried to force users to install .NET Framework SDK by setting it as Prerequisite in ClickOnce (under Publish -> PreRequisite) solved the issue but it does not make much sense to ask users to download a 350+ MB package and install it just to get a dll. There has to be a easy way out.

So I started thinking of alternatives. Any application looks for dlls in GAC only after it has looked in to the current directory. The solution was to push Microsoft.mshtml.dll in to the bin directory.
By default if you go to Project Properties -> Publish -> Application Files you will see something like :

app files

Clickonce correctly identifies Microsoft.mshtml.dll as a prerequisite but has marked "None" as the dowload group i.e. it does not get downloaded to the user's machine. To enable it going in to the user's machine, you can just mark the Publish Status of the dll to "Include (Auto)" . You will see the download group automatically being changed to "(Required)". Now publish it.
Clickonce will now identify the dll as a required download dll so will download it to the user's workstation. While installation, the Interop dll's will find Microsoft.mshtml.dll in their current directory hence will no longer look in to GAC for the dll and the install will go on smoothly.

And this is a cheaper a better solution too.

Saturday, August 1, 2009

USB Mass Storage Issues - v2

In an earlier post USB Mass Storage Issues I talked about uninstalling MS Windows drivers and installing Intel drivers.
Today I found the issues again and found that my drives are too old. To check for your drivers check the Intel site : http://www.intel.com/support/graphics/detect.htm . Please get the latest Intel drivers and install them. Post install you should have the latest chipset drivers and you USB should be working fine.

P.S: Ealier I preferred Intel over MS drivers. Therafter I read more documentation at the Intel site and found that Intel is supporting USB driver updates from Windows update site. So for latest drivers you can get it from MS Windows update site too. Still check for the latest updates at the Intel site too.

Friday, July 24, 2009

Virtual Provider Error

Recently I faced a Virtual Provider issue on which I spent considerable amount of time but to no avail. The issue is reported multiple times in google and also in Microsoft Bug 307978 and is even marked as closed but it still comes up.
The error message is:

The VirtualPathProvider returned a VirtualFile object with VirtualPath set to '/MasterPageDir/SharedMasterPage.master.cs' instead of the expected '//MasterPageDir/SharedMasterPage.master.cs'.

All the posts mentioned that its a compilation error but how to find it out. I tried a lot of code but did not help. So the solution is:
Use EventViewer. Under Application the error will be logged as a ASP .NET 2.0 error. Looking at the details you can figure out the details of the compilation issue. :)

Saturday, May 16, 2009

How to work better

Was reading in the net and found this usefule advice:
  1. Do one thing at a time.
  2. Know the problem.
  3. Learn to listen.
  4. Learn to ask questions.
  5. Distinguish sense from nonsense.
  6. Access change is inevitable.
  7. Admit mistakes.
  8. Say it simple.
  9. Be calm.
  10. Smile :)

Friday, May 8, 2009

Enable Upload of Documents in Dokuwiki

Recently I installed Dokuwiki on IIS as the wiki for my team and projects.
The installation went on fine but it did not allow upload of images, documents, pdfs etc.

Looking through the internet I was able to find the solution step by step.
So I have consolidated all in here:


  1. I have my wiki installed at C:\Inetpub\wwwroot\wiki. I created an upload folder to allow php engine to write files in there. I got in created at C:\Inetpub\wwwroot\wiki\uploads and gave Domain\Users , Internet Guest Account and Launch IIS Process Account "Full Control" over the folder. This allows IIS worker process to write files to the folder.

  2. I have my php installed at C:\PHP. Open the C:\PHP\php.ini file and make the following changes:

    1. Look for the config param "open_basedir" and set it to wiki base directory.

      open_basedir = "C:\Inetpub\wwwroot\wiki"

    2. Look for the config param "upload_tmp_dir" and set it to the Uploads directory created in Step 1.

      upload_tmp_dir="C:\Inetpub\wwwroot\wiki\uploads"

    3. You may also want to set the maximum file size that can be uploaded. Look for the config params "post_max_size" and "upload_max_filesize" and set it to the required file size.

      post_max_size = 20M
      upload_max_filesize = 20M

    4. Just confirm one more thing i.e. the config param "file_uploads". It should be set to ON.

      file_uploads = On

    5. You may also want to set the mail setting for php application under the "[mail function]" section. You will need to set the config params "SMTP" (SMTP server), "smtp_port" and "sendmail_from".

  3. This should set you up and you should be able to upload to your dokuwiki.

Happy wiki'ing.



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.












      Sunday, March 22, 2009

      Quotes from "The Curious Case of Benjamin Button"

      Saw the The Curious Case of Benjamin Button a few days back. There were some quotes worth mentioning:-
      • It's a funny thing about comin' home. Looks the same, smells the same, feels the same. You'll realize what's changed is you.
      • Our lives are defined by opportunities, even the ones we miss.
      • You never know what's coming for you.

      and the most important to me was:

      You'll see little man, plenty of times you be alone. You different like us, it's gonna be that way. But I tell you a little secret I find out. We know we alone. Fat people, skinny people, tall people, white people... they just as alone as us... but they scared shitless.

      Sunday, March 15, 2009

      Thru You

      Thru You stands for:-
      1. The true power of internet.
      2. The creativity of the masses and not just classes. Normal humans do have creativity. All that needs is mixing them to create a masterpiece.
      3. Good music can be open and popular and not just copyrighted. Its on youtube for all to watch.
      4. The potential of viral marketing. Remember it just started with a mail to 20 people to over a million views in a week.
      5. Good people like Kutiman do exist.

      Visit it for sure.

      Tuesday, March 10, 2009

      USB Mass Storage Issues

      This all started with the 2009 New Year Party. Someone spilled some beer on my laptop and I started facing strange USB issues. So I uninstalled a few thinsg and things went worse. Sometimes the mouse wont work but a simple plugout-plugin makes it work.

      Last week I tried to work on my external USB hard disk storage device and it simply did not work. Windows initially reported an error like:


      Application popup: Windows - Delayed Write Failed : Windows was unable to save all the data for the file G:\$Mft. The data has been lost. This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elsewhere.


      Then it stopped recognizing it completely reporting Unknown Device.
      So here's the way to troubleshoot it:
      1. Check whether the USB external storage is working or not: I plugged in my USB external storage to another laptop and it worked. So the USB drive does not have any issue.
      2. Check whether the laptop USB port is working or not: I used the same port for my mouse and even a keyboard and it worked. So the USB port does not have any issue.

      So the problem is neither with the USB port nor with the USB device so what's the problem. The problem is the special USB feature which Mass storage devices use i.e. USB 2.0. So how to check it:

      1. Go to the "My Computer" icon and do a right click + Properties. Select the "Hardware" tab on the top. You should find a "Device Manager" button in there.


      2. Open the device manager. At the end of all components, you will find "Universal Serial Bus Controllers" (USB Controllers). I have 4 USB ports which are listed below and I have a USB 2.0 controller which sits on top of these 4 USB ports and enable USB 2.0 technology for all the 4 USB port.

      3. Now the problem which we face with Mass storage drives is that they use this USB 2.0 Enhanced port. Other USB devices like mouse, keyboard, webcam use only standard USB features.
      4. You might see all these elements in your Device Manager too. The problem lies with the driver which might have been corrupted. So to remedy it.
      5. Select the USB2 Enhance port controller and do a Right Click + Uninstall. These will remove the existing USB2 driver.
      6. To play safe (and to start from scratch), do a Right Click + Uninstall on the other 4 USB Controllers too. You will see the USB Root Hubs disappearing from the list.
      7. Once the whole list of items under "Universal Serial Bus Controllers" is empty, go to the menu on the top and select Action -> Scan for Hardware Changes.
      8. Your Microsoft Windows OS will automatically detect the USB port and will install its default drivers for them. Note: It might detect the USB2.0 controller too and install its driver for it but the MS driver does not work. If it does it automatically, uninstall it as in Step 6.
      9. So now all your ports are USB compliant. Plug in your mouse and see that it works fine.
      10. Plug in you USB mass storage hard disk. It will recognize it but will report a faster USB2.0 device inserted to a slower USB1.0 port. Hurrah !! - we have got out USB mass storage hard disk working although at slower speeds.
      11. Now we need to enable the USB2.0 controller. To do you need to get your original chipset driver cd. If you have it, good or browse to your laptop's vendor page and loop for chipset driver for your laptop.
      12. Install your chipset drivers again. The USB 2.0 drivers are part of chipset drivers collection.
      13. Post this, check in device manager. The USB2 Enhanced controller will be recognized. If you do a Right Click + Properties to it and go to the Driver tab on top, you will see the driver details (and it will be a non-Microsoft driver).
      14. Plug you USB mass storage hard disk again and it should work fine this time:)

      P.S: More details on USB can be found at wikipedia.

      Wednesday, February 18, 2009

      The BAD News : Tech Layoffs Surge to 300,000

      So worldwide the number of tech employees who have been laid off recently has crossed 300,000.

      For details and updates, read the article at techcrunch.

      Monday, January 19, 2009

      SQL Server 2005: Change schema for Tables and SPs

      SQL Server 2005 copied the schema concept from Oracle. Earlier the user and schema used to be same for SQL 2000 but from 2005, these are two different things.
      Now when we migrate a SQL 2000 DB to SQL 2005 server, we face a problem. We find that the objects i.e. Tables and Schemas are owned by the user and not [dbo].
      So now to make [dbo] (or some other schema own it) execute the following scripts:

      Table
      SELECT 'ALTER SCHEMA NewSchema TRANSFER ' + TABLE_SCHEMA + '.' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'OldSchema'

      SP
      SELECT 'ALTER SCHEMA NewSchema TRANSFER ' + s.Name + '.' + p.Name FROM sys.Procedures p INNER JOIN
      sys.Schemas s on p.schema_id = s.schema_id WHERE s.Name = 'OldSchema'