basquang™ on clouds

April 26, 2014

[WP8.1]: Changing Windows Phone 8.1 WebView default User-Agent in all outbound HTTP requests

Filed under: Microsoft Technology,Tips,Windows Phone — basquang @ 10:07 AM
Tags: , ,

Recently, I’m developing Windows Phone 8 app which hosting our cloud services. We need to add some custom HTTP Headers in to requests. Unfortunately, Windows Phone 8 WebBrowser control doesn’t have properties to set custom User-Agent by default. The only way you can do is the method:

webBrowser1.Navigate(new Uri("", UriKind.Absolute), 
null, "User-Agent: your custom user-agent");

But with this method, you are able to pass your custom user-agent in first request only. With outbound HTTP request, meaning all web link in your site, the webBrowser1 will using device’s default User-Agent.

You can check your current user-agent here:

By the release of Windows Phone 8.1, now you can set your custom User-Agent for entire process by using Win32 API: UrlMkSetSessionOption

Using following code to make your user-agent by default for all outbound HTTP request in WebView control on Windows Phone 8.1

[DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);

const int URLMON_OPTION_USERAGENT = 0x10000001;
public void ChangeUserAgent(string Agent)
      UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);

void MainPage_Loaded(object sender, RoutedEventArgs e)
      ChangeUserAgent("My Custom User-Agent");
      wb.Navigate(new Uri("", UriKind.Absolute));

Hope this help!



June 27, 2012

TFS 2010: Analysis Database corrupted

Filed under: Microsoft Technology,TFS,Tips — basquang @ 10:56 AM

Sometime TFS analysis database TFS_Analysis may get problems. For examples:

Error 1: Unable to get the required information about this cube. The cube might have been reorganized or changed on the server. The PivotTable was not refreshed.

Error 2: Detailed Message: TF221122: An error occurred running job Incremental Analysis Database Sync for team project collection or Team Foundation server TEAM FOUNDATION.
Exception Message: Error encountered when creating connection to Analysis Services. Contact your Team Foundation Server administrator. (type AnalysisServiceConnectionException)

Error 3: Exception Message: File system error: The following file is corrupted: Physical file: \\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Dim Team Project.0.dim\330.ProjectPath.ksstore. Logical file .
Errors in the metadata manager. An error occurred when loading the Team Project dimension, from the file, ‘\\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Dim Team Project.330.dim.xml’.
Errors in the metadata manager. An error occurred when loading the Team System cube, from the file, ‘\\?\C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data\Tfs_Analysis.0.db\Team System.1191.cub.xml’.
(type OperationException)

In these cases you may have to rebuild the Cube and Warehouse of your TFS.

To rebuild the cube and warehouse, following these steps:

1. Delete analysis database TFS_Analysis

– Go to SQL Server and locate the folders contains TFS_Analysis database C:\Program Files\Microsoft SQL Server\MSAS10_50.MSSQLSERVER\OLAP\Data

– Delete following files and folder: Tfs_Analysis.0.db, CryptKey.bin, Tfs_Analysis.0.db

Restart SQL Server Analysis Database service

2. To recreate the Tfs_Analysis database, please refer to the following steps:

– Launch TFS Admin Console | Application Tier | Reporting, in the right panel, click Edit to open the Reporting window.

– Under the Analysis Services tab, input the Tfs_Analysis under Database textbox, and re-provide the required account under Account for accessing data source.

– Click Ok to generate the Tfs_Analysis database in Analysis Services.

– Click Start Jobs and Start Rebuild to rebuild warehouse and the Analysis Services database.
The similar way to recreated Tfs_Warehouse database under Warehouse tab in Reporting window.

Hope this help!

October 15, 2010

SyntaxHighlighter on

Filed under: Tips — basquang @ 11:09 AM

function EnableRibbonButton() {
    var items = SP.ListOperation.Selection.getSelectedItems();
    var ci = CountDictionary(items);   
    var listId = SP.ListOperation.Selection.getSelectedList();
    return(ci > 0);

The display of code can be generated from

HTML Editor in page:


Create a free website or blog at