How to deploy the devexpress control during installation

Source: Internet
Author: User

In my winform development framework or WCF development framework, various interface style options are provided, one of which is the devexpress control interface style with better interface effects, but we usually use it in the development environment, and the installation package size is large, more than 100 mb. How should we perform this operation when deploying the application to the client?

We analyzed the special patches of devexpress and found that they are a DOS batch processing file, mainly to create the corresponding directory, and then copy the three special files of devexpress to the corresponding directory, you can achieve normal use of devexpress. The content of the DOS batch processing file is as follows.

Generally, we create an installation package when deploying a client application. You only need to correctly execute these doscommands in the custom installation operation.

However, during the ghost installation process, gacutil.exe will use the system directory as the initial Directory, which will cause the above operation to fail. The corresponding directory cannot be found because there is no gacutil file under the default system directory, and no devexpress file to be copied. data. v11.1.dll and other DLL files. So how can we correctly execute the doscommand to successfully deploy several special DLL files of devexpress?

1. First, create an installation project, add the above special registration file to the installation package, and then modify register. add a PATH variable "{install_path}" to the content of the BAT file, which will be replaced with the specific path name during installation. The modified file is as follows.

 @ Echo   Off 

Set Path = "{Install_path }"

Gacutil-U "{install_path} \ devexpress. Data. v11.1"
Mkdir % Windir % \ Assembly \ gac_msil \ devexpress. Data. v11.1 \ 11.1.6.0 _ b88d1754d700e49a
Copy "{Install_path} \ devexpress. Data. v11.1.dll" % WinDir % \ Assembly \ gac_msil \ devexpress. Data. v11.1 \ 11.1.6.0 _ b88d1754d700e49a

Gacutil-U "{install_path} \ devexpress. utils. v11.1"
Mkdir % Windir % \ Assembly \ gac_msil \ devexpress. utils. v11.1 \ 11.1.6.0 _ b88d1754d700e49a
Copy "{Install_path} \ devexpress. utils. v11.1.dll" % WinDir % \ Assembly \ gac_msil \ devexpress. utils. v11.1 \ 11.1.6.0 _ b88d1754d700e49a

Gacutil-U "{install_path} \ devexpress. coderush. Common"
Mkdir % Windir % \ Assembly \ gac_msil \ devexpress. coderush. Common \ 11.1.6.0 _ 35c9f04b7764aa3d
Copy "{Install_path} \ devexpress. coderush. Common. dll" % WinDir % \ Assembly \ gac_msil \ devexpress. coderush. Common \ 11.1.6.0 _ 35c9f04b7764aa3d
Rem Copy "{install_path} \ devexpress. coderush. Common. dll" C: \ Program Files \ devexpress 2011.1 \ id1_ls \ System \ dxcore \ bin \ devexpress. coderush. Common. dll"
If "[% ProgramFiles (x86) %]" = "[]" ( Copy "{Install_path} \ devexpress. coderush. Common. dll" "% ProgramFiles % \ devexpress 2011.1 \ id1_ls \ System \ dxcore \ bin \ devexpress. coderush. Common. dll ") Else ( Copy "{Install_path} \ devexpress. coderush. common. DLL "" % ProgramFiles (x86) % \ devexpress 2011.1 \ id1_ls \ System \ dxcore \ bin \ devexpress. coderush. common. DLL ")

Echo 'OK'
Pause

2. After creating an installation package, add a custom installation project named installeraction, and create an "InstallProgramClass, as shown below

The project is as follows:

 

3) Then we modifyCodeOverwrite the install function, which is mainly used to replace the PATH variable "{install_path}" of the register. bat batch file, as shown in the following code:

[Runinstaller ( True )]
Public Partial Class Installaction: Installer
{
Public Installaction ()
{
Initializecomponent ();
}

Public Override Void Install (idictionary statesaver)
{
Base . Install (statesaver );

Try
{
String Physicalroot = This . Context. Parameters [ " Targetdir " ]; // Installation physical path

Try
{
// When the register.batfile is executed, gacutil.exe uses the system directory as the initial directory,
// Therefore, set a parameter in the BAT file and replace it with a specific directory during installation.
String Register = path. Combine (physicalroot, " Register. bat " );
Replacename (register, " {Install_path} " , Physicalroot );
}
Catch {}

String Registerfile = path. Combine (physicalroot, " Register. bat " );
Rundos (registerfile, "" , False );
}
Catch (Exception ex)
{
Writelog (ex. tostring ());
}
}

/// <Summary>
/// Replace the specified name in the script with a new term before running the script.
/// </Summary>
/// <Param name = "filepath"> Script File Name </Param>
/// <Param name = "olddbname"> Original Name </Param>
/// <Param name = "newdbname"> New name </Param>
Private Void Replacename ( String Filepath, String Oldname, String Newname)
{
If (Newname. compareto (oldname )! =0 )
{
String Filetext = String . Empty;
Using (Streamreader = New Streamreader (filepath, encoding. Default ))
{
Filetext = streamreader. readtoend ();
Filetext = filetext. Replace (oldname, newname );
}

Using (Streamwriter =New Streamwriter (filepath, False , Encoding. Default ))
{
Streamwriter. Write (filetext );
}
}
}

/// <Summary>
/// DOS file execution in the background
/// </Summary>
/// <Param name = "FILENAME"> File name (including path) </Param>
/// <Param name = "argument"> Running Parameters </Param>
/// <Param name = "hidden"> Hide window? </Param>
Private Void Rundos ( String Filename, String Argument, Bool Hidden)
{
Process = New Process ();
Process. enableraisingevents = False ;
Process. startinfo. filename = String . Format ( " \ "{0 }\" " , Filename );
Process. startinfo. Arguments = argument;
If (Hidden)
{
Process. startinfo. windowstyle = processwindowstyle. hidden;
}
Else
{
Process. startinfo. windowstyle = processwindowstyle. normal;
}
Process. Start ();
Process. waitforexit ();
}

4. In the custom installation view of the installation package, associate the custom installation project to the installation package, as shown below.

Modify the property items of the main output from installaction as follows:

5. Compile and run the program. We found that the DOS running effect is as follows, which indicates that the DOS command runs normally and the file is copied.

6. Run the program. The devexpress interface is displayed normally and no additional forms are displayed. This is what we need. The example interface is shown below.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.