Sunday, December 23, 2012

SQL  Server Mirroring Tips

A few days ago I had to fix yet another SQL Server mirroring issue.

So here are some practices I have adoped on how to make it work right. Before diving into this, though you should be very keenly aware that Mirroring uses host name based encryption just like the SSL on a web server. If the hostnames do not match against its' certificates then you will not have a connection.

Don’t Use The Servers’ Hostnames

This absolutely sounds not intuitive, but here is the deal. If you are multi-homing your server, or having a Hyper-V running on your machine, chances are you have unintentionally left the “Auto Register DNS” mode in your TCP/IP control panel. If you do not know what I am talking about then, it is very likely that you will run into this situation, since “Auto Register DNS” seems to be on by default.

Don’t bother even thinking about it. No need to understand it and no need for a full time network engineer looking out for your situation.

The deal is that the IP address to Hostname mapping can quickly go wrong as people change the IP addresses on the control panel etc. If you are running Hyper-V or multi-homing then there are more than one IP addresses assigned to a host name.

Unfortunately, the Mirroring works basically only with a pure Fully Qualified Domain Name (FQDN). Which means that a single IP address must be mapped to a single host name.

So don’t let the OS determine this for you. Ask your IT folks and create Dedicated Hostnames for your SQL Servers and have them enter those statically into their DNS, and just for an extra measure edit your on C:\Windows\System32\Drivers\Etc\Hosts file and put the FQDN and addresses of the hostnames involved in mirroring (i.e., primary, secondary and witness – note I did not say Principal, Mirror and Witness, I said primary, secondary and witness since any of primary and secondary can be a principal at any given time.)

For example you have a primary and secondary as and then I’d separately create and And have those entered manually into your domain’s DNS.

Now You Have Defined the Dedicated Host Names…

Connect with the SQL Server using the FQDN of the newly defined server using the FQDN string. For example, if you have an instance called TOMORROW, connect the database as\TOMORROW

This will ensure that subsequent mirroring configurations will use the FQDN.

Configuring for Mirroring -- Security End-Point  Setup Step

Use the newly created FQDN when establishing the security end-points to connect to other database servers. Do not connect to the original server names.

Even if you take good care in doing this, the SQL Server still decides to change the FQDN of the endpoints, and that's the very reason it breaks or mirroring not establishing right.

After the end-points are set up, DO NOT start mirroring immediately. Instead check the end-point strings to have the FQDN. Typically SQL server reverts all or some of the string to the original host name, and that’ exactly not what you want.

Half-Established Mirror Databases -- Recovery Technique

Somethings the mirroring begins to establish and fails. The mirror side goes into the "mirrored" but disconnected mode. This can happen when you may have not typed in the FQDN correctly, and after realizing that you made a mistake, you tried to re-configure the end points, then you are only to get a Database Instance is Not Online or Available message.

You may recover from this condition by
  1. Going to the mirror side
  2. Enter "ALTER YourDatabaseName SET PARTNER OFF"
If the database goes into the "Restoring" mode, and if you try to re-mirror by entering the correct FQDN and also checking the correct FQDN before starting the mirroring.

Thursday, November 01, 2012

C# Windows Forms - Calling Main Form Methods from A Thread

I am a bit embarrassed to say that I don't write much Windows Forms code these days since most of my work are done as web based apps. But, I sometimes need to whip up some desktop apps that are simple quick to do DB operations and such.

Desktop apps can provide very interactive user expriences without resorting to complex JavaScript codes. To this effect the use of threads in Windows forms code is pretty much a must to update the form status etc., live. But how to tie these threads to the main UI thread is often a very puzzling experience, especially if you don't do this very often or coming from the ASP.NET world.

People who do not understand various mufti-threading issues like memory areas and concurrency go ahead and call methods in the main thread directly from sub-threads. This works probably half the times if lucky and other times, the program crashes due to some memory violation.

Anyhow, I do not do these often enough to the point that I can't remember how to do this right off the top of my head, so here I am going to write this article for myself here so the next time I have to do it, I can come back here and remembered how to do it.

I am going to include a Visual Studio 2010 project containing the prototypical clock update app. This app updates the clock time on the main form from the thread that's running every 100 ms. This also has the thread stop, abort and cleanup part too.

The Example ZIP is HERE.

Some Key Concepts
  • You need to declare a Delegate in your class. This is simply a template that models a function call. I made a mistake of trying to use this as the instance to the method. Don't think too hard about it. It is kind of like what you do in the .H file in C++ The delegate becomes a Type just like String and Double.
  • Knowing that the Delegate is just a type (i.e., you cannot call it directly), you would want to declare the instance of it next in the (main form) class. I would do both the delegate and declaration of the actual instance right next to each other. 
  • Then within a class constructor, assign the Entry Point of the actual function to the delegate instance.
  • In the thread that wants to call a function in the main thread, use the Main Form's Invoke method. This means that you would pass the Main Form object to the thread, and the thread uses MainForm.Invoke method supplying its delegate instance and parameters if any. The key here is that the actual Main Form object is passed on to the thread object and that the Invoke method out of the main form is called. This is the part which is not very intuitive to me, since it is the MainForm object in the main thread after all, so it cannot be so clear to me what can actually be mucked with directly from the thread.
  • Also note that Invoke() does NOT have to come from the Main Form. Any controls that are contained in the main form appears to be a fair game and since all the controls have the Invoke method, you can use the same technique in the example against some control object (or subclass of thereof).
Once you understand and get a hang of it, you can expand it in more complex ways like doing this against subforms, or subclasses of controls etc.

Try it and let me know what you think!

Friday, October 19, 2012

Error message 401.2 After Installing a Web App on One Server But Not The Others


I have a standard ASP.NET application that works fine with any other IIS 7 server, but on a very specific server when I installed my application the I get the following error.

Access is denied.

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.  Contact the Web server's administrator for additional assistance.

I have done everything obvious like;
  • Check to make sure that application pool is run by a specific user, in my case Nework Service
  • Made sure that the above user has the full access. In fat, in desperation I have tried to make Everyone Full Control, and still I had above error.
Root Cause:

I did not write II7, so I do not know exactly why in one case it is like this way. Not quite undrestood at this time.


Yes, I was able to work this issue around, and this may as well be the right solution.
  • From the IIS 7 manager, go to the application to directory. You should see on the right panel the familiar ASP.NET and IIS sections with a bunch of icons.
  • Under the ASP.NET section, double click .NET Authorization Rules
  • Under the Actions panel all the way to the right click Add Allow Rule...
  • When the dialog appears select "All users"
Now try accessing the web page again.

Note, I am not responsible for any security related issues specific to your web application. This is a workaround for me, I do not care so much about security since in my situation the page is well deep behind firewalls and no public access.

Friday, October 12, 2012

ASP.NET: 'GridView1' fired event Sorting which wasn't handled. Even with LinqDataSource in Use


  • I have written an ASP.NET application with a GridView (any bound control) and enabled sorting on the control. 
  • I have manually "swapped" the LinqDataSource by another. In my case I have several that contain different Dynamic LINQ statements in them. Next thing you get the following error and the columns will not sort.

The GridView 'GridView1' fired event Sorting which wasn't handled.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:
System.Web.HttpException: The GridView 'GridView1' fired event Sorting which wasn't handled.

Root Cause: 

You are likely to have assigned a LinkDataSource to the DataSource properly. This will not work.


If your situation is exactly like mine, like below:

       if (false==String.IsNullOrEmpty(like))
            GridView1.DataSource = this.LinqDataSourceDateDesc;
            GridView1.DataSource = this.LinqDataSource2;

Then this will not work.

Fix this to use the ID of the Data Source, and the event for the sort will hook right back up again.

       if (false==String.IsNullOrEmpty(like))
            GridView1.DataSourceID = "LinqDataSourceDateDesc";
            GridView1.DataSourceID = "LinqDataSource2";

Side Note:

Often when I get stuck with a problem like this, I write a simple test program that would demonstrate the situation. In this day and age, many application projects are already scaffoldded so it's just easy to come up with something quickly. In my case the grid was working initially when I built everything from the designer but as soon as I try to go fancy by assigning the data source, it broke. So this way I went back reproducing basically the original flavor, then looked at the source (in this case in the Default.aspx) and that worked, and quickly realized that it is the DataSourceID they use to bind, no other codes to hookup the events were in this simple code. 

I have seen many novice engineers getting stuck for hours or even days on an issue. If they simply wrote a case to demonstrate the issue then they could have spent much less time fixing the issue.

Monday, October 08, 2012

Apple Mountain Lion Upgrade: Why Wait Until Weekend is a Good Idea

Mountain Lion is a highly recommended upgrade and it is less than $20 to get. Besides in order for you computer not to be obsoleted you should upgrade as more and more apps will come out that only works for the later OS versions.

So, of course, you should be wondering why upgrading your Mac to Mountain Lion should be done on weekend.

If you are ready, I would schedule a time of upgrade and I recommend that you do this a few hours before you go to sleep.

This is because Mountain Lion upgrade is a "production interrupting" event, and it will actually not make your computer usable reasonably for up to several hours. In my radiology job, this is very customary, we do not upgrade any computers until all the radiologist are gone home.

After the computer boots up when the upgrade is applied and you log on, there are two things that are very time consuming.
  • Some re-indexing activities like building of Spotlight and such. Many people have reported that Mountain Lion is "slower" but this is because initially it takes a while for this rebuilding activity to complete. So leave it alone and let it finish and it will be faster.
  • As I wrote in another article, Mac Mail files must be migrated from the original location to the new "sandbox" location. This can take hours to complete in some cases.
So my best recommendation is to do this upgrade Friday at 9 PM. Let is do its thing over night (be sure to turn off auto-sleep). And you can reserve Saturday and Sunday to sort out various post-upgrade thing, if necessary to talk to the Apple Genius, back ready for production on Monday.

Mac Mountain Lion: Mail Migration Taking Forever or Never Completes


We upgraded a Mac from Lion to Mountain Lion. After launching the Mail program, it says "Migrating" but it takes quite a while until the progress bar goes to 100% then it hangs.

Workaround (may not be a fix):

I do not have sufficient time to diagnose this completely but the reason for the migration is that it needs to copy all of the files in the Mail storage from one location to another. This is likely for a better security.
  • First, be aware that a lot of people do not manage their email. They simply have thousands and even millions of email messages, attachments and even undumped email trash. So this will take quite a while. I would do this over night to see if it was just taking time. Be sure that you change the computer sleep time to "never."
  • One possibility is that Microsoft Entrouge may be affecting it. I know a good chunk of people do not use Entrouge so in our case, I just dumped the entire Entrouge in the trash.
  •  Next, restart your Mac in the Safe Mode. Note that this can take about 10 - 20 minutes of its own time before it starts. This is because the Mac needs to do a process of file system check before allowing you to use it in the Safe Mode. Do not panic. Just let it do its thing.
  • Be sure to set the computer sleep time to Never. It will still be several hours of processing!
  • Launch the mail, and see if it starts, head for your favorite club, dance all night, come home sleep whatever left of the morning. When you wake up, do not go to the computer, make coffee or tea, take shower, dress and go back to your computer... and voila! I think your computer is showing the usual email list.
  • Note: Please do not post a comment if it does not work. Instead call Apple for support. I do not work for Apple and I myself do not use Mac Mail instead just check my email on the web or I use Nexus 7 Android tablet and iPhone. Perhaps you would want to start using web email just in case this sort of thing happens in the future. If you want to manually clean the email data, they are stored under ~/Library but you would want to search such topic using your favorite search engine provider.

Sunday, September 30, 2012

Firefox 16, Mac OS Mountain Lion, Fixing Missing QuickTime "Plug-In"


You have a recent version of Firefox and you run into a page that requires a QuickTime plug-in.
It asks you to install the plug-in manually but there is no way to do it. You probably looked for it everywhere and even Apple web site says, "it comes with your Mac already."

Root Cause:

It appears that if you have a QuickTime plug in file in  /Library/Internet Plug Ins/QuickTime Plugin.plugin this issue can occur. It also appears that this isn't really needed.

I had this Mac for quite a while with all different versions of Firefox running, so I would not be surprised if the old plug-in was not removed when it had to be after a certain version of Firefox.

Work Around:

If you hesitate to do any of these "internal" activities below, then try using Safari browser. That's I have been getting around before I found this answer.

Possible Fix:
  1. Quit Firefox
  2. Open your Finder and head to /Library/Internet Plug Ins/ and cut QuickTime Plugin.plugin and paste that onto the Desktop or any other directory outside of it. In fact you will need this since Safari will need this. 
  3. Start Firefox again.
  4. Try the page with Quick Time again
Note that if you remove the QT plugin, it apparently breaks Safari's ability to play the QuickTime.

Friday, September 28, 2012

"Dead" iPhone 4 (or 4S) Solution


This is what happened this morning. For no good reason at all, the phone was off completely when I went back to it. I know I made a call earlier in the morning.
  • Normally off-phones can be turned on by pressing the power button for 5-10 seconds. This time, it did not respond.
  • Normally if it is completely out of battery, it will also show some charging sign when it is plugged into the charger. This time, that did not happen.
  • I left it on the charging stand thinking that at some time the battery charging sign would come on. It never did.

Try holding the big square "home" button in the bottom middle of the phone and power button pressed together for good 30 seconds or longer, and it worked for me.

Side Note:

This never happened to my iPhone 4 for the entire 3 or so years I owned it. I upgraded it to OS 6 recently, that may have something to do with it, and it might happen again because of this. If so I will post again if this tends to happen a lot now. Also ironically, it just happened at the time I was several weeks (looks like some delay) before my iPhone 5 arrives. If it was completely dead, I am certainly in a big bind, and may be forced to move to an Android phone.

Saturday, September 22, 2012

Using Windows PuTTY with SSH Keys

Well, I am embarrassed to say that it took me a bit of time to figure out how to log into a Unix system using PuTTY and SSH keys.

I could not find (or understand) this information easily in the PuTTY document site. I felt that this information is assumed to be known. So if you landed on this page, then you have the same issue as I had. Note that from Unix to Unix, the instructions are straight forward as to where you would store the keys and such. This is an article about the Windows PuTTY.

Based on my experimentation there are two ways that the SSH Key can be loaded. Once way is to specify the Private Key (I did not say Public Key) portion in the PuTTY configuration. I will explain this in a moment. And the second way is to use Pageant.EXE. The latter approach is the one I actually like better but both will work.

First, if you have never done this sort of things, then you are a bit out of luck as I am not going to explain how to use Puttygen to generate keys and where to find Pageant and the like. I can, however, give you one quick way to get those loaded is to install Tortoise Git on your windows.

Now, assuming that you got keys generated and stored them somewhere kind of safe (I put mine somewhere in my own Documents folder so only I can see it and not others on the network.)

Here are some key things you need to remember to do.
  • Start your PuTTY
  • Create a new profile, but most importantly you should set your user name in the [Host Name] field. For example, admin@  Otherwise, your user name get prompted for and also the password too. This is more important if you are using Pagent to log-in.
  • If you are NOT using Pageant
    • Before you press that [Open] button, navigate to Connection: SSH: Auth node on the  Category panel.
    • You will find [Authentication Parameters] field. In there you specify the location of your Private Key.
    • Then you should go back to the Session node and save current configurations.
    • In this approach you will have to supply the password each time you connect, which kinds of defeat the purpose of using the keys.
  • If you are using Pagent, then the prime advantage of this is that once you give the password for the private key then from that point on you can log in to any SSH sessions that is associated with your key pair while its running without supplying it again.
    • Add your private key in Pageant. You can access Pagent from the notification tray section.
    • If it is not running, you will have to manually start it from the start menu where Pageant is stored.
    • (Note you may still have to do the Key Load part into the session as described in "If you are NOT using Pagent" but I did not have to. If I have to do that I will update this article.)
    • You do still need to load the key to Pageant each time you log into your Windows session.

Wednesday, September 19, 2012

Nexus 7 Screen Capture Does Not Work. It Actually Does.


I have learned that you can do Volume-Down plus Power simultaneous button press to capture the screen as a part of the Jellybean feature.

I tried this many times and it did not work. Only thing I saw coming up was the volume control.


The buttons work as advertised. I was not doing this right (as with a several other people posted this complaint). I was thinking that by pressing these buttons the screen shot starts right away. And that's where I was wrong.

The real trick is this.
  • Press the power and volume down button simultaneously and hold both buttons pressed for 1-2 seconds (and be patient) until the screen capture completes.
  • Note that if the volume thing comes up on the screen you messed up the timing of simultaneous pressing. Release both fingers and try again.
  • You could also be inadvertently pressing both Volume Up and Down simultaneously as you do this. Try holding the volume button really towards one edge. (Never use your thumb ;-) 
  • Do you have a teenager handy? Ask him or her try it. If it works with them, then, well, the machine is fine.

    Good luck!

Monday, September 17, 2012

java_sp.dll Corruption Issue, Version 7 Update 7


I was updating a Windows 7 Home Premium system with Version 7 update 7, and got java-sp.dll error and could not proceed. It was an account with a local machine admin privilege.

My Fix:

Open the download folder where you downloaded the installer and "Run as Administrator".

Time Wasted:

About 20 minutes.

Friday, July 13, 2012

Hyper-V Desktop OS Internet Access Shared Host IP Address

What I Wanted To Do?

I have client-server type deployments and some of the applications only run on Windows XP as a desktop application. Occasionally, I need to run the app while servicing the server at the same time. It is thus a bit more convenient to launch a desktop OS running under Hyper-V from the same server. I really don't care if I cannot access it remotely outside of the server. Obviously, Microsoft thought that this use case is a rare one on servers, but I guess I understand...

Unfortunately, unlike VMware or Virtual Box, Hyper-V does not (seem to) provide a convenient Shared or Bridged configuration which would share the server's (host's) IP address to get out to the network outside. It does, by default, extends the network to the outside so if there is a DHCP server on the network, and if you are permitted, you can run the guest OS.

How I Solved It?

I have found this post from John Paul Cook very comprehensive and usable. Just in case we all lost an access to the post, here is the basic stuff you need to do.
  • Add Network Policy and Access Services Role
  • This will subsequently allows you to add Routing and Remote Access Services. Add Remote Access Service and Routing. Note that you already may have this installed.
  • From your Hyper-V manager, create a new Interface and give it a private IP address like ( This will become the "router gateway" address for your guest OS.
  • Assign this interface in your Guest OS
  • In the server manager you will now find Routing and Remote Access. Create a Network Address Translation item.
  • Select the Destination (NAT target) as your host's interface that's on the network.
  • Select the Source as the private interface you've just created.
  • Start the Guest OS, configure the new interface with its own IP address in the private subnet and point the gateway address to the address of the interface you've just created (where I said Also add DNS addresses.
  • Turn off Windows Firewall settings for the interface.
  • And test.

Sunday, July 08, 2012

Visual Studio 2010: The specified module could not be found. (Exception from HRESULT:0x8007007E)

Update: After the Windows 8 Release, this article became one of the top reads! This is mainly because you probably installed Visual Studio 2012 then realized that it broke your 2010. This is something even Microsoft support does not readily know!

  • You have installed Visual Studio 2012 recently while having Visual Studio 2010 SP 1
  • You then open the Servers and connect to an SQL server (either 2008 or 2012) from VS 2010
  • Try to create a table in one of the connected database.
  • You get an error "The specified module could not be found. (Exception from HRESULT:0x8007007E)"
  • Additionally if you want to design the DBML with LINQ to SQL, you cannot drag a table into the Design Surface

When you installed VS 2012 it has "corrupted" with the following DLL version that does not work right in VS 2010.

C:\Program Files (x86)\Common Files\microsoft shared\Visual Database Tools\dsref80.dll


Note that "repair" of Visual Studio will not work. Do not go down that path! You pretty much need a completely clean installation of this, as it is in the shared file. So do not waste your time.


Find a system that never had a Visual Studio 2012. Harvest dsfre80.dll  and copy this to the same location on your damaged computer and you are good to go.

At worst case, create a Virtual Machine, for example use the free Virtual Box, install a VS 2010 on it and harvest the file.

Saturday, June 16, 2012

LinqDataSource Control "Exception has been thrown by the target of an invocation."


  • You are running Visual Studio 2010 SP1
  • You have an ASP.NET web page
  • You have dragged the LinqDataSource onto the design surface
  • You try to Configure Data Source and get the following error message
 Exception has been thrown by the target of an invocation

Root Cause

  • Appears to be Related to .NET Framework 4.5 present (as a result of installing Visual Studio 2012).

Fixes That Would Not Work

I have tried the following and none worked. So you may not want to go down the same path.
  • Use devenv /Log to find out what's happening.: It will not log anything useful.
  • Start devenv in /Safemode.: No effect
  • Repair Visual Studio 2010
  • Uninstall Visual Studio 2010 (note if you do this you will have to apply SP1 which takes a long time)
  • Remove or Repair Sliverlight SDKs
  • Remove or Repair .NET Framework 4.5

Possible Fix If You Do Not Need VS 2012

The following steps fixed my situation. You do not need to uninstall SQL 2012 Express
  • Uninstall VS 2012
  • Uninstall .NET Framework 4.5
  • Uninstall .NET 4.0 Multi-Traget Pack
  • Using VS 2010 Installer, Perform the Repair of VS 2010

Workaround If You Need VS 2012

  • Try another machine or a VM you have not installed anything "2012" on it, you should be able to continue to work on LinqDataSource. Once the LinqDataSource is configured, check the code in and it should work on your "corrupted" environment, though you won't be able to change anything in the data source. You can still work with the Data Grid to which the data source is connected and do add/remove columns and such. You can manually edit the web page source code to change minor things like some query changes.
  • If you can safely move up to VS 2012, then the LinqDataSource will work perfectly fine there.

Thursday, June 14, 2012

Firefox: WebGL Not Functional: Blocked for your graphics card because of unresolved driver issues


WebGL does not render at all on some graphics cards on the latest/later Firefox browser for Microsoft Windows for example Firefox 12. If you look at the Help->Troubleshooting page (or simply type in about:support in the URL) on Firefox, you see

WebGL Renderer Blocked for your graphics card because of unresolved driver issues.

By now, you probably figured you need the graphics driver installed (which is the first thing you should try), but still to no avail.

But if you use Google Chrome, WebGL probably works fine. The good way to test this is to go to the Chrome Experiments web site. For example,

Root Cause:

There is a fairly limited set of conditions in which WebGL is activated with the Google ANGLE WebGL rendering engine which Firefox for Windows uses. Rather than crashing the browser when WebGL functionality is dicey, Firefox has a Driver Blacklist and it is very likely that your graphics card and/or the driver version has been blacklisted.

Some graphics cards are simply not supported yet as they cause crash, which leads to poor user experience and developers do not want that to happen for regular users. Also since anything outside of NVIDIA and ATI will not be supported, unfortunately.

If you are using Remote Desktop, then the WebGL driver will be automatically disabled.

In addition to the model of the graphics card, if your laptop contains NVIDIA Optimus Technology, which allows you to use both GPU and the integrated (e.g., Intel HD 3000) graphics on laptops, then it is also subject to be blacklisted by Firefox, even if the base desktop model of the GPU works OK with Firefox. This was my situation.


  • If you do not have NVIDIA or ATI graphics card, all bets are off. If it is a desktop, you could swap the card with at least some mid range "gaming" class graphics cards.
  • You cannot use Remote Desktop or most other ways to delegate the graphics driver such as virtual machines. Walk over to your computer and use its own display.
  • If you have a laptop computer with Intel Graphics integrated then turn off your GPU. I have the Intel HD 3000 graphics on my laptop and actually the built-in GPU works fairly well on Firefox. I get about 40 FPS with the HD 3000 and 60 FPS with the GPU on.
  • If you have read above mentioned black list article on the Firefox Wiki, it explains the way to force-enable WebGL. This, however, will be a very risky proposition and may render your Firefox  unusable. So if you don't want to risk this much and Chrome is working for you I would suggest you stick with Chrome for WebGL. These days, it is always good to get used to more than one browsers. Note that Internet Explorer and Apple Safari do not directly (out of the box) support WebGL.

Tuesday, June 12, 2012

Visual Studio 2010 Startup Very Slow


When I launch the MS visual studio 2010, it is really slow in coming up.

My Root Cause:

There are of course many root causes of this, but in my specific situation, it was the Microsoft Fusion Log left enabled.

I had to diagnose assembly loading errors previously using Fusion Log and I configured and left this on. This will cause a significant slow-down in your computer operations.

My Fix:

First you can check to see if Fusion Log is enabled. You can generally find this out by running the new Resource Monitor that comes with Windows 7 and 2008 family of OS. You will find that there is a lot of disk I/O with respect to the fusion logs.

Second you can check in the Start Menu, under Visual Studio 2010 -> Microsoft Windows SDK Tools -> Fusion Log Viewer

You may find this in the situation where the logging is stuck and you cannot disable it.

If you find that you cannot disable it, you many need to do the following registry tweaks. You may not find all of the keys, but do not worry, just remove the ones that are still there.


Remove the following keys


Conversely, if you want to re-enable fusion logging...

DWORD ForceLog set value to 1
DWORD LogFailures set value to 1
DWORD LogResourceBinds set value to 1
String LogPath set value to folder for logs, for example D:\FusionLog\

Restart your computer just to be extra sure and you should be fine after this.

Monday, June 11, 2012

IE 9 Crashes on MSN


You open IE 9 and go to   IE 9 crashes with the "Internet Explorer Stopped Working" dialog box.

Root Cause:

I do not know. I am suspecting that it is the Flash player.


  • Try manually re-installing the latest version of Adobe Flash player. In my case this has corrected the issue.
  • If going to MSN is only your goal, MSN works perfectly fine with Firefox or any other non-Microsoft web browsers.
  • If you have to use the IE for testing and debugging and such, you can go to Internet Options on the control panel and make the home page to Blank.

Saturday, June 09, 2012

VS 2010 Web Debug Fails To Start Due to "Invalid file name for file monitoring"


You try to launch your ASP.NET web application from Microsoft Visual Studio (2010) and you get the following error (you swear it was working an hour ago.) Note that the file name mentioned does not really matter. The symptom is that you cannot launch a web page in debug mode.

Invalid file name for file monitoring: 'C:\Blah\Whatever\App_LocalResources'. Common reasons for failure include:


The root cause is completely understood, but it has something to do with catching all un-handled CLR exceptions in the debug menu.

My Fix (May Not Work With You):

  • Go to Debug->Exceptions and un-check all un-handled exception checking.
  • Try to launch the debug session again. This time, it worked for me.
  • Go to Debug menu and then clear all break-points. This time, I can re-enable un-handled CLI exceptions and back to be able to launch and debug the app.
  • If above does not work, clear the .NET temp files for the framework version you are using. For example,

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

Tuesday, June 05, 2012

Windows 7 Desktop Freezes Up But Start Menu OK


For "no obvious strange reasons" (actually for a good reason, see the cause below) the Windows 7 desktop suddenly freezes. For example, you cannot "right mouse click" on any items on the desktop. But Start Menu works just fine.


This turns out to be iexplorer.exe process not completely closing down. You can find out if this is actually your case by going to the task manager and manually killing the iexplore.exe (may have *32 next to it if you are running a Windows 7 64-bit version)


This may be due to the IE configuration or plug-ins being messed up. You can optionally reset the IE settings using this information.

IE is totally a fine browser but you can use Firefox as your default browser and you can avoid this problem in exchange for possibly other problems.


Around June or July of 2012, my Google Chrome is starting to exhibit similar behavior. I am investigating but usual "clean everything" seems to be working.

Saturday, June 02, 2012

Visual Studio 2012 Show Stopper Collections

Just installed the VS2012 RC a few days ago. I am tallying any show stoppers.

SQL CLR "Corruption"


I had an MSMQ triggering CLR in SQL Server 2012 Express. It seems that after installation of VS2012 the assembly stopped working.

When the assembly was called from a stored procedure, I got a message somewhat like this:

Server: Msg 6522, Level 16, State 2, Line 1
A .NET Framework error occurred during execution of user defined routine or aggregate 'getsid':

System.IO.FileLoadException: Could not load file or assembly 'System.Messaging, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)



You can correct this condition by ALTER ASSEMBLY. For example, if the Messaging DLL is corrupted in the above manner, I would do;


Note, be sure to exit Visual Studio 2012 when you do this. You may get yet another issue which results in "Out of Resource" error.

Other Possible Issues:

  • Exception has been thrown by the target of an invocation when dragging in the LinqDataSource control. -> See This Article

Wednesday, May 16, 2012

SQL Express Connection Times Out Even Though It is Up


I can access the local SQL Express server instance without a problem using the SMSS, but from my application the SQL connection times out almost immediately.


In my situation, it was a connection string issue. In production I use a mirrored connection. So just out of a laziness, I just change two of the hosts in the connection string to be the same.

Like this,

Data Source=localhost;Failover Partner=localhost;Initial....

Apparently the driver does not like this type of conneciton string and give you an immediate timeout error.


Just remove the Failover Partner part and try. It always does the trick to me.

Monday, May 14, 2012

WFC Services Runs OK on Visual Studio Web Server But Not on IIS When Deployed


You have created an WCF "web" service. It debugs and runs fine on the Visual Studio's web server, but when deployed the directory to the IIS 7 (even on the same local machine) you get a script error.

The Root Cause

The WCF is not fully enabled on your IIS 7.

The Fix

The complete fix is from this web site at Microsoft. 

  • Open the IIS manager and Go to the Default Web Site, Double-click Handler mappings in the Features View.
  • In the list of application mappings, verify that the .svc file for the .NET Framework in use (2 or 4) is mapped to the aspnet_isapi.dll. If the file has not been mapped:
  • Click Add Managed Handler.
  • Type *.svc into the Request path:.
  • Type System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 into the Type textbox.
  • Type svc-Integrated into the Name: textbox.
  • Click OK.
  • Click Add Script Map.
  • Type *.svc into the Request path:.
  • Type %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll into the Executable: text box.
  • Type svc-ISAPI-2.0 into the Name: text box.
  • Under the right "Actions" Panel, select "View Ordered List" then Using the Move Up/Move Down controls, ensure that the managed handler (svc-Integrated) appears before the aspnet_isapi (svc-ISAPI-2.0) handler in the list.
  • Click OK.
  • Give it a shot.

Visual Studio 2010 Reloads Microsoft.VisualStudio.IDE.ToolboxControlsInstaller,ToolboxInstallerPackage'{2C298B35-07DA-45F1-96A3-BE55D91C8D7A} Every Time


When opening a forms designer on Visual Studio the following toolbox loads each time and it takes a long time by loading the toolbox with the following information.


Root Cause

When you installed a later version of Sliverlight SDK, it has corrupted some data in the older version of the SDK (it is rather complex matter that I fully do not, nor tired to, understand.)

Possible Solution:

There are various options on this, and the best discussion about this is at this URL:  But it appears that this is related to Silverlight SDK corrupting some data in the SDK based on this post.

There are other discussions on this post.

In my specific case, setting

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Packages\{2c298b35-07da-45f1-96a3-be55d91c8d7a}\Toolbox\DefaultItems to 0

made it worse.  I cannot recommend this.

Instead try un-installing and re-installing the Sliverlight SDK in the order of versions to fix the toolbox issue. Namely remove 5.0 SDK and 4.0 SDK then install the 4.0 first then 5.0 if you are still (having to) coding with Sliverlight.

As with anything, approach your fix with a big caution when dealing with config issues like this. Have a good back-out plan like backing up the registry settings etc.

If you don't care so much about Silverlight...

Because of my situation for needing to go beyond Mac and PC audience I have to avoid using Silverlight so I do not need it. If you are on the same camp as I am, just blow away the key altogether.


For Additional Insights,

You may want to read this article from Infragistics people about How Visual Studio 2010 Toolbox Works.

Thursday, May 10, 2012

ATT Momentum 4G Adaptor Blue Screens Windows 7 X64


When you plug in ATT Momentum 4G (Sierra Wireless Momentum), you get a blue screen (with memory violation from a driver) when the driver in being installed.

Root Cause:

I do not know exactly which driver causes this, but...

It appears that the Sierra driver is not compatible with the USB-3 interface (at least on my ASUS u46s). Try plugging this into a USB-2 interface slot and start the installation over again.

Also, in my situation, I had to call the ATT's automated activation phone line to activate the SIM in it.

Thursday, April 26, 2012

Collecting PDF Form Data with ASP.NET C#

I recently had to investigate the technique to capture the form input data collected on Adobe PDF for radiological procedure report results.

This, though very simple, information was scattered around all over the places so I can provide you the gist of what you need to do by means of a simple demo code.
  • First you will need to use the PDF Form Editor, for example Adobe Acrobat Pro. I am sure there are a lot of different ones.
  • Next you either scan a form or create one which output the usual .doc file.
  • Import the document and edit the form using the PDF form editor, drag and dropping the fields.
  • Finally add a submit button with a submit action of http://localhost/xfdf
  • On Visual Studio, create the xfdf web project and you can add the following code in Page_Load of Default.aspx
public partial class xdf : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        var name = "junk.xfdf";
        string filename = Path.Combine(Server.MapPath(""), name);
        using (FileStream fs = new FileStream(filename, FileMode.Create))
            byte[] bytes = new byte[8192];
            int bytesRead;
            while ((bytesRead = Request.InputStream.Read(bytes, 0, bytes.Length)) > 0)
                fs.Write(bytes, 0, bytesRead);
  • Compile above code.
  • Submit the PDF form to the URL
Then if you open junk.xfdf on your text editor, you will see something like this. The key part is that you will see the field and value elements in the XML. From this point it is quite easy to parse this stuff using the XDocument class and LINQ.

<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="" xml:space="preserve"
><field name="Heart Rate"
><field name="Submit"
><ids original="BFF11731D28F744F901901CF60BBED7A" modified="B0328D96D4E3F242A93BC5512C7B97E6"

Monday, April 09, 2012

Getting XTIDE Up on Joyent SmartMachine (Solaris 11)

This is my note on getting the XTide (learn more) up on the Joyent SmartMachine on which I am running various personal web projects. My XTide was previously hosted on a shared Linux machine (i.e., no root access) before but the provider upgraded the Linux and then it broke. Since I now have an Intel Solaris 11 virtual machine of "my own," I have decided to transition to this server (as I find time, of course.) Installing and configuring XTide on a shared machine was a real hassle as they did not have X11 installed and they won't install it for me, but now with the virtual machine in which I have the "root" things are becoming much easier, in addition there are a lot of pre-built installs that's available (still require the root access.) {Why Joyent SmartMachine and Solaris? Don't ask. But I am extremely satisfied with it. }

Perhaps you may have the same problem and here is how I got around the issues.

Note that I am only interested in running this as a command line to compute the tide and graphics in the area I surf using a cron job. So if you have an X-Windows issue, this article won't help much.

Getting It Installed

Getting it installed is fairly simple.
  • The page tells that on Solaris you go to Blastware.COM, but almost all of the mirror sites it points to are broken. Instead, if you go to it is still avilable. The maintenance of this stopped around 2.10 (in 2008) but for my purposes, it is OK. Someday, when I have more time, I may volunteer to contribute to Opencsw to maintain this. Not now...
  • It comes with required libraries, and also the original harmonics and wvs files it was built with in /opt/csw/share/xtide 
  • If you don't know what I am talking about but you have the root access to the machine, just follow the instructions on the OpenCSW web site, install the pkgutil installer first as a root (if you don't have) and then install the xtide with it. You would be all set in a matter of 5-10 minutes. And if you still don't know what I am talking about, then it is best to ask your IT admin buddy to get that done as it can affect other OpenCSW packages other people may be using on your machine. 
Getting it to Run
  • "Out of the box" by typing in {tide -l "princeton"} it did not run. In fact it threw an exception about saying  the following:


    but do not dismay yet...!
  • Here is what I have done to get it going!
The "tide" command on /opt/csw/bin/tide is a shell script which, in turn, will run tide.bin after "tide" sets various environment variables. There appears to be an issue with the WVS_DIR environment variable and if only have the HFILE_PATH it works (in other words comment out WVS_DIR definition in the tide script), and it will output the tide. The graphics output also worked.

To test if anything works, you can first only EXPORT the HFILE_PATH in your shell then run /opt/csw/bin/tide.bin directly like this.

/opt/csw/bin/tide.bin -l "princeton"

The Harmonics Database Location Names Have Changed

In my old script I had -l "half moon bay." This time it did not work as the program could not find the station name. So be sure that you look at the Location List (  that matches your Harmonic file you've downloaded.

Hope this helps in your situation.

Saturday, April 07, 2012

ASP.NET GridView and LinqDataSource Stuff...

The DataGrid is one of the components I use quite a bit in my line of work, and they are convenient.

I have also been using LINQ quite a bit. It is a significant time saver as well as making my code more easier to understand. But until today I never bothered to use LinqDataSource just because I did not spend time to learn a bit about it. Instead I always built the DataSets using the designer. The problem with the Datasets for me is that it does not show me exactly what I am querying easily.

Before I get into that, I have to tell you also that if your requirement is very simple, then you can feed the result of the Linq query directly to the GridView (or other data binding controls.) This might be a great way to bind the pull down menu or a list view with small number of selections.

For example,

var customers = from c in context.customers select c;
gridview1.DataSource = c;

And that really all it takes to feed a GridView. For more information on this, learn from this MSDN page.

But this won't allow you to sort or page the grid. For that purpose you need to attach a LinqDataSource. You can easily do that by:

  • Defining the LinqToSQL object in your project, or pull one in from other assembly
  • Dragging and dropping the LinqDataSource component on to of the GridView. The wizard will show you which of the LinqToSQL database context object to use.

Well that's great, but I really do not want to use the connection string that's built into Web.config. In my case, I pull the connection string common to all my applications from my own company's registry set. But at any rate, you would assign a newly created data context to e.ObjectInstance of the event argument.

So here is another trick.
  • Define an event processing method for ContextCreating event.
  • Re-instantiate the LinqDataContext class object with your connection string. Yes, just the Context is all you need here. The rest will be handled with the LinqDataSource you've created with the designer. (Yes, it is the Data Context object, not the Linq Select result.)

       protected void LinqDataSource1_ContextCreating(object sender,
           LinqDataSourceContextEventArgs e)
            string myConnectionString="your connection string";
            e.ObjectInstance = new MyDataConext(myConnectionString);

Here is another bonus thing you can do. If you do this type of connection string swapping, it is best to create a new context factory class of your own and then call that. This factory class can do the connection string swapping for you. This will centralize the connection string swapping.

In my case, the connection information is stored locally in a registry and many of my own applications pull that information from there at run-time. This way, all I need to do is to set the connection strings once and then all other applications I write will not need separate connection configurations. There are of course many other ways of doing it.

Sunday, March 25, 2012

Mac Lion: ssh hangs


On Mac Lion (10.7.3), when you try 'ssh' it times-out. You know you have the proper login and host parameters because it works from other computers (say Linux or Windows putty, or even running putty on the same Mac!)


I do not know, but it appears that the Mac Lion SSH handles UTF-8 character sets in the manner that the remote side do not like.

There is nothing wrong with your network or network provider. Something wrong is introduced in Lion.


Essentially finding a line in /etc/ssh_config file that says LANG LC_* should just be commented out. If you do not know exactly what I am talking about the following is the steps to accomplish this.

  1. Open Terminal
  2. sudo vim /etc/ssh_config
  3. Supply your password
  4. Type in below, including the first /
  5. /LANG LC_
  6. This will take you to the line where the problem is
  7. Hit the left arrow key several times,  until you are at the start of the line.
  8. Type i to insert
  9. Type # to comment out the line
  10. Press ESC to exit the insert mode
  11. Type wq (means write quit) to save the file and exit vim
  12. Now close the Terminal, Re-launch it and try ssh again
If you do not want to all of this, simply download other SSH clients and use them.

Saturday, January 21, 2012

Fix! Pythonwin (2.x) Windows 2008 Event Log Text Get Empty String


You used to be able to get the Event Viewer text under Windows 2003 using the following call in Pythonwin. After switching to Windows 2008 or Windows 7 the strings are all empty!


for ev_obj in events :      
   msg=str(win32evtlogutil.SafeFormatMessage(ev_obj, logType))

Now the majority of "msg" comes out blank. Oddly enough any newer programs the msg come out fine.


The string messages logged can also be found as tuples in (using above code example) ev_obj.StringInserts as UNICODE strings.

Therefore, for example, to grab the strings as one msg string, you could write a quick loop like this to get you the full string.

                               msg = ''
             for si in ev_obj.StringInserts :
                   msg = msg + si + ' '                               
             print msg