Monday, March 29, 2010

Resolving IE z-index problem of all controls

The following code resolves all z-index problem :
/*Fixing menu z-index problem and all z-indexing problem of IE */
$(function() {
var zIndexNumber = 1000;
$('div').each(function() {
$(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});
});


Happy coding ...

Thursday, March 25, 2010

Unregister an assembly using regasm.exe command

You might know that to register an assembly you can use 'regasm' command.

But what if you want to unregister this assembly ??
To unregister an assembly using regasm.exe command that had been registered before. You could you can add a /unregister to regasm syntax :
'regasm /unregister [assembly full path]'

Wednesday, March 24, 2010

Using Command Prompt for running SQL commands

Usually on the costumer's computer, if you installed an instance of Microsoft SQL Server Express, you will not install the management studio to prevent the user from using it badly and harm your valued database. But in this case you might need to run a SQL command.

You can use the command prompt to do the job.

From command prompt you can run a 'sqlcmd'.

The simplified syntax for that is 'sqlcmd -S servername'. ex. 'sqlcmd -S adel-pc\SQLEXPRESS' and now you are on the sever and you can run any Select, Update, delete , backup, restore .. etc comands or any sql command you want by accessing database for example 'USE master GO' and so on ...

You can find here a full description of sqlcmd.

Have fun.

Tuesday, March 23, 2010

Ajax Control Toolkit : ScriptManager and .net framework 3.5 'AjaxControlToolkit' is undefined (javascript)

Problem
When moving an ASP.NET application that uses AJAX and has an update panel from .net framework 2.0 to .net framework 3.5 you might have a problem that 'AjaxControlToolkit' is undefined although you have included it and it works on the developer PC.

Actually this problem makes me hit my head on a wall as I did not see any reason for that error.

I looked for an Ajax Extensions msi setup for .net framework 3.5 but thanks to Microsoft it is included in .net framework 3.5 setup. So what is the problem.

Solution
In such situation googling will not provide you with a satisfactory answer for that. But I hope that after this post, I might save you tons of hours looking for a solution.

In Script Manager I have added a CombineScripts="false" property and it do the trick :)

So what is it means. Read the following paragraph that will illustrate in details:
The ToolkitScriptManager class derives from ScriptManager and enables the automatic combining of multiple script files in the corresponding web page. Any scripts (and localized script resources) coming from assemblies indicating their willingness to have their scripts combined (with the new assembly-level ScriptCombine attribute) will automatically be combined into one file for download by the user's browser. This combining action (and the automatic compression of the resulting file) can dramatically reduce the number of round-trips made by the browser to fetch scripts and correspondingly improve the page's responsiveness. The combined script file will be cached by the user's browser just like its individual parts would have been with the ASP.NET AJAX ScriptManager's default ScriptResource.axd behavior. Any changes to the page or the associated DLLs invalidates the cached copy of the combined scripts and prompts a re-download during the next page access.

This new behavior is enabled by default for ToolkitScriptManager and can be disabled by setting its CombineScripts property to "false". Assemblies containing scripts which should not be combined in this fashion for some reason may use the ScriptCombine attribute's ExcludeScripts/IncludeScripts properties to specify exactly which scripts can be combined. The absence of the ScriptCombine attribute on an assembly means that none of its scripts can be combined in this manner; this is an explicit opt-in model for Assemblies.

Thursday, March 18, 2010

WIX Deployment

The following is a setup setups using WIX including additional important info. That you might find in a hard way.


  1. Install WIX (15 MB)

    http://sourceforge.net/projects/wix/files/


  2. Build your application as release.
  3. Run heat.exe command given full paths for any input file or directory. This will generate application.wxs file that contains GUIDS of release components.
  4. Use the following command to remove unwanted files from the released application files:

    xcopy RELEASE_PATH EXECLUDED_PATH /EXCLUDE:exclude.txt /E /Y

    where execlude.txt is a text files that contains unwanted files' extentions. Its content might be as follows:

    \.svn

    \Properties

    \obj

    \Helper

    .pdb

  5. Refer to WIX website to build your WIX deployment application.
  6. Install BootStrapper Manifest Generator that matches your Visual Studio version from here.
  7. This will help you to create prerequisites for your application.
  8. Finally you can use a .pat file to gather all in a single file. This .pat file may contains a code like this:

    C:\Program Files\WinRAR\WinRAR" a -r -ep1 SETUPNAME SETUP_OUTPUT_PATH\* -s -sfx -zAnswers.diz -iiconico107.ico -m0


    You have to note that WinRAR application should be installed, and Answers.diz is a .diz file that may contains a code like :

    Overwrite=1

    TempMode

    Title=SETUP_TITLE

    Silent=2

    Setup=setup.exe


    And ico107.ico is an ico file that will be the icon of the generated setup file. So that your setup including the prerequisites can be in a single setup file.


WIX - Add an assembly component to GAC

Reader background
- Windows Installer XML setup (WIX)
- Global Assembly Cache (GAC)
- My previous post on WIX

Problem
You need to install an assembly to GAC.

Solution
After genertion of wxs file of the assembly component using heat.exe command, you need to add it to GAC.

After googling and looking for a solution, finally I found it and it was very simple and makes the job as I want.
The solution was to add two properties tothe file of the component:
  1. AssemblyManifest. (set it to the file Id)
  2. Assembly. (set it to .net)
Try it and I hope that it helps you.

Thanks

Tuesday, March 16, 2010

My WIX setup important notes

Windows Installer Xml (WIX)

The Windows Installer XML (WiX) is a toolset that builds Windows installation packages from XML source code. The toolset supports a command line environment that developers may integrate into their build processes to build MSI and MSM setup packages.
When using WIX you might -sure actually- face many problems. I tries here to save you a time with a common tools that might help you.
I started using it since 2009 and now I am on 2010 and I need it again.
I tried to find tools I was using before and here I will add it one by one to easily find it and share it with all of you.

Let's Start

- Heat.exe
Heat is used to generate WiX authoring from various input formats.Every time heat is run it regenerates the output file and any changes are lost.
You have to note here that you should enter full paths or you will get an endless errors that you will never know its reason !!

- Setup Log
If your MSI doesn't work properly, how do you troubleshoot? The easiest way is to turn on tracing to get the setup log file. The command line is:
msiexec /i product.msi /L*v log.txt

- Cabarc
Generates a .cab file if you want to install a component from your web application. This component might be a .net activeX control.
Click here to install it.

-Microsoft Visual Studio 2008 Web Deployment Project
If you want to use WIX for a web project. You might need 'Microsoft Visual Studio 2008 Web Deployment Project' which is a Visual Studio 2008 Web Deployment Projects provide additional functionality to build and deploy Web sites and Web applications in Visual Studio 2008. This add-in provides a comprehensive UI to manage build configurations, merging, and using pre-build and post-build tasks with MSBuild.


I will update everytime I need a new command or tool. Thank you