Thursday, December 3, 2009

Solved problem with SQL Server Management Studio (SSMS) in Windows 7 X64

I was trying connect to database via SQL Server Management Studio in windows 7, and got following message.

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). (Microsoft.VisualStudio.OLE.Interop)

I have tried all the solutions I found in the internet:

But none of them works for me.

However, I finally got the problem solved by removing my anti-virus software AVG 9.5.
Hope this will help other people.

The same problem back again after I disable UAC, and restart computer.
I have to enable UAC again to fix it.

Update 2:
There is an easy way to fix is just to run SSMS as administrator

Wednesday, November 18, 2009

Silverlight 4 beta released

Silverlight 4 Beta has just released On November 18, 2009.


Check it out at:


New features which I was look forward to:

-          Mouse wheel support for scrollable controls (no additional behaviour is required)

-          Right click support

-          Clipboard support

-          Full editable design surface for VS2010



It could be good fun to move to SL4 soon.

Thursday, October 29, 2009

Monday, October 12, 2009

How to determine an webresponse stream type

               WebRequest request = WebRequest.Create(url);

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();


                if (response.ContentType.StartsWith("text/html", true, CultureInfo.CurrentCulture))


                    //Html page


Thursday, October 8, 2009

Up comming: Silverlight: how to scroll to target element in ScrollViewer or nested ScrollViewer

   public static class ScrollViewerExtension 
/// <summary>
/// Scroll to the current element, if there is has an parent scrollviewer
/// </summary>
/// <param name="target"></param>
public static void ScrollToElement(this UIElement target)
ScrollToElement(target, null);
/// <summary>
/// Find next level scrollviewer, and scroll to the target element
/// </summary>
/// <param name="target"></param>
/// <param name="childScroller"></param>
private static void ScrollToElement(this UIElement target, ScrollViewer childScroller)
ScrollViewer scrollViewer;
if (childScroller == null)
scrollViewer = ParentOfType<ScrollViewer>(target);
scrollViewer = ParentOfType<ScrollViewer>(childScroller);
if (scrollViewer != null)
if (scrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible)
UIElement scrollContent = scrollViewer.Content as UIElement;
GeneralTransform gtToContent = target.TransformToVisual(scrollContent);
Point offsetToContent = gtToContent.Transform(new Point(0, 0));
GeneralTransform gtToScroller = target.TransformToVisual(scrollViewer);
Point offsetToScroller = gtToScroller.Transform(new Point(0, 0));
if (offsetToScroller.Y < 5 offsetToScroller.Y > scrollViewer.ViewportHeight)
scrollViewer.ScrollToVerticalOffset(offsetToContent.Y - scrollViewer.ViewportHeight / 4);
ScrollViewer parentScroller = ParentOfType<ScrollViewer>(scrollViewer);
if (parentScroller != null)
ScrollToElement(target, scrollViewer);
//TODO: Log exception message here
private static T ParentOfType<T>(UIElement currentElement) where T:DependencyObject
return currentElement.GetVisualAncestors().Where(p => p is T).FirstOrDefault() as T;

Thursday, August 13, 2009

Silverlight Design Time Error

Siverlight User Control Design Time Detection.


if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))




Internal Error 2235 with MSI installation

I am trying to build a simple MSI installation from Wise Installation Editor.

Build OK, test on one PC is fine, however, when I test it on another machine, I get the following error:


Internal Error 2235. ,RuntimeFlags, Select 'Component','RuntimeFlags','KetPath','Attributes'FROM 'Component'WHERE 'Component' =?



    There is no component item at MSI component table.



Add a dummy component node under component table. And build it again.



SQL Bulk copy, is much better then execute insert scripts

Copy whole table:

1. Generate insert script by loop the table rows, execute it

Simple, anyone can do it

2. SqlDataAdapter.Update(table)

Dim builder As New SqlCommandBuilder(adapter)
adapter.InsertCommand = builder.GetInsertCommand(False)

For Each tmpRow As DataRow In dtResult.Rows
adapter.Update(dtResult) 'Insert data here

3. SqlBulkCopy

Dim bCopy As New SqlBulkCopy(ConnExpress)
bCopy.DestinationTableName = tbName

4. SMO (Microsoft.SqlServer.Management.Smo) (Microsoft.SqlServer.Management.Common)

ScrollBar issue with FlexGrid in Compact Framework

The scrollbar of C1FlexGrid displayed very small in VGA mode.


Problem: Scrollbar not resize will in VGA mode


1. Set form draw mode to "DPI"

2. At form.load event, set grid.Size = me.Size.