Friday, May 20, 2011

Installing Expresion Blend 4 SP1

If you get the message "Upgrade not applicable" when trying to install Expression Blend 4 SP1, this is most likely because you already have the Windows Phone Development Tool installed.

WPDT will install a copy of Blend with SP1 to design Windows Phone Silverlight app.

If your version of Blend is : 4.0.20901.0, then you already have the SP1 installed.

Expresion Blend 4 SP 1 Download page

Labels:

Monday, May 09, 2011

Running Visual Studio Load Test

If you are creating a load test in Visual Studio, the load test result will be saved to a SQL Server database.

There is a one time setup which you need to do in order to save the result into the database.

1) You need to create the database schema in a SQL Server database. To do this, run the following sql script in SQL Server to create the database:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\loadtestresultsrepository.sql

Note : Use 'Program Files' if you are on 32bit. Use 'Program Files (x86)' if you are on 64bit.
Use 'Microsoft Visual Studio 10.0' if you are using Visual Studio 2010. Use 'Microsoft Visual Studio 9.0' if you are using Visual Studio 2008.

The default database name is 'LoadTest2010' (for VS 2010) and 'LoadTest' (for VS 2008).

2) You need to configure the database connection string in Visual Studio so that the load test know where to save the test result. To do this,
go to menu Test -> Manage Test Controller, then click on the browse button to enter you connection string.




You only need to do these steps once. The same database will be used for all load tests for all projects.

If you do not do the above steps, you won't be able to see result after you run the load test.

Labels:

Save Fiddler Session as Visual Studio Web Test

Fiddler enable you save a recording session as 'Visual Sudio Web Test'. The web test can then be added to the Visual Studio test project.
This function used to be acceesible from menu File -> Save.

However, if you are using a newer build (release since early 2011), this function has been moved to File -> Export Session. You can choose 'Visual Studio Web Test' from the dialog drop down.

Labels: ,

Sunday, February 20, 2011

Hidden configuration for Firefox

There is another way to tweak configuration in Firefox. Type 'about:config' in the location bar and hit <enter>. Firefox will then display a configuration screen which has more configuration options than you can find in the normal Tools -> Options.

Labels:

Sunday, June 20, 2010

Creating a Web Setup Project for asp.net Application Using Visual Studio

This is a tutorial how you can create a simple web setup project for your asp.net application. We will also add a new wizard step into the msi setup wizard to allow user to choose which environment he is installing and the msi will deploy the appropriate web.config specific for that environment.


1. Create a new Web Application project in Visual Studio


2. Insert the following appSetting into web.config


3. Copy paste the web.config 3 times and rename to the following file name:


Each of the 3 files contain configuration that is specific to their environment(development, SIT and production). You can add more configuration to the config file depend on your application need. We will use these files in the web setup project later.

4. Update each of the new web.config to reflect its environment:


5. Add a new Web Setup Project into the solution.


After you add the Setup project,
Select the Web Application Folder, in the property window, modify the virtual directory name. This is the default virtual directory name which will be installed into IIS. You can change this later during the installation. If you cannot see the Web Application Folder, select the Web Setup project, in visual studio menu, go to View -> Editor -> File System.




6. Right click in the Web Setup project and select Add -> Project output.



7. Make sure the web application in the current solution is selected, then select Primary Output and Content files. This will add the binaries and necessary files into the msi for installation.


8. Right click in the Web Setup project and select Add -> Files. Add the three environment specific web.config file into the setup project.


Now we will begin the steps to add a new dialog to our installer. This dialog will enable user to choose which environment he want to install and the installer will deploy the appropriate web.config file to the installed folder.

9. Make sure the Web Setup Project is selected. In the visual studio menu, go to View -> Editor -> User Interface. You will now see the list of dialogs which will be presented during the installation time.


10. Right click on the Start node and select Add Dialog.


11. Select the Radio Buttons (3 buttons) dialog


12. Right click on the new dialog you just added and select Move Up. This is to re-order the sequence of dialog presentation during installation time.


The dialog sequence should look like this after you complete the step.


13. Select the Radio Button dialog, and in the property window, modify the property value to match the following:



The value of the ButtonProperty is the name which will be used for lookup later. The value you specified for ButtonProperty is case sensitive. The ButtonValue is the value which will be set into the lookup name specified by te ButtonProperty. For example, if you select SIT, "2" will be assigned to ENVIRONMENT.

14. Now select the web.config_dev in the Web Setup project. In the property window, set the Condition and target name to match the following:



Repeat the same for web.config_sit (set the condition to ENVIRONMENT="2") and web.config_prod (set the condition to ENVIRONMENT="3")
If you specify a condition, the file will only be install if the condition is evaluated to true. The value for ENVIRONMENT is assigned in the Radion Button dialog depend on which radio button you select. Remember "ENVIRONMENT" is case sensitve. It has to match the ButtonProperty value which you specified in the Radio Button dialog.
The TargetName is the actual name for the file when it is copied into the installed folder. In this case, we want to rename it to web.config


15. Next, we want to exclude the original web.config file from the web application project. The final web.config will be copied from either one of three environment specific web.confg file. In the Web Setup project, right click on the Content Files, select Exclude Filter.



Add web.config to the filter dialog and click OK.


You can now build the installer and run the MSI to install your web application. Remember to run the MSI as administrator if you are in Vista and above.

You will see the installer wizard dialog as following:
This is the standard dialog for web appliction.


This is the dialog which we add to allow user to choose the installation environment.


After the installation complete, you can open the web.config to verify the correct file for that environment has been installed.

Labels: , ,

Encoding XML Special Characters

To encode string which has XML special characters so that it can be inserted as valid text into xml node, you can use the following API in System.Security namespace.

string s = System.Security.SecurityElement.Escape("<>&");

This will produce the following output:

&lt;&gt;&amp;

Labels: ,

How to XML serialize simple type as different element name for Generic Collection Type Argument

For web service method's parameter which is a generic collection with simple type as the type argument, the type name will be used as the XML element name in the array child node by default.

Example, if below is your web service method

[WebMethod]
public string DoWork1(List<string> partNames)


The soap message will looks like the following:


However, you can change the XML element name by specifying a XmlArrayItem attribute to the method's parameter


[WebMethod]
public string DoWork2([XmlArrayItem(ElementName = "blah")]List<string> partNames)

Labels: ,

Wednesday, March 10, 2010

Finding files in your drive using command prompt

There is a command line called where for finding files in your drive:



where /R . gacutil


The command above find the location of gacutil recursively(/R) starting from the current directory.

Labels: , ,

Tuesday, November 17, 2009

Quick (and dirty) way of finding impact of field changes

If you are going to change a database table field and want to know what stored proc or UDF will be affected, you can use the following query as a quick and dirty way to find out which stored proc or UDF is using that field.


SELECT routine_name, routine_definition
FROM INFORMATION_SCHEMA.routines
WHERE ROUTINE_DEFINITION LIKE '%TextToSearch%'
ORDER BY last_altered DESC

Labels:

Tuesday, December 02, 2008

Extra blank page when Save to PDF from SQL Reporting Service

When you save a report as PDF from Sql Reporting Services, you might see an extra blank page in between the pages in the report. This is due to the actual print out size exceed the page size that is specified.

For example, you specify your report size to be width (11 in) x height (8.5 in) which is a A4 size. However in the body of the report, you might have specify (intentionally or unintentionally) the size to be larger than that. When you save the report to PDF, you will see a blank page because the report size actually run over the page size.

To solve this problem, make sure you check the Size and Margin property of both the Report and Body (you can access this from the properties window).

Labels: , ,

Visual Basic Divide operator

For non profressional Visual Basic developer it might not be apparent that VB has two divide operator.

The first divide operator which is more commonly used is '/'. This operator will return the result with decimal
if the number being divided (also call dividend)
cannot be fully divide by the divisor.

The second divide operator '\', which is also called integer division will always return the result (also call Quotient) in integer.

Labels: ,