Wednesday 15 September 2010

c# - How to make Wix call function inside a DLL without errors? -



c# - How to make Wix call function inside a DLL without errors? -

my issue windows has issues accessing dll installtools.dll since i'm calling function within openexeurl

here dll content

using system; using system.collections.generic; using system.linq; using system.text; using microsoft.deployment.windowsinstaller; using system.configuration; using system.diagnostics; namespace installtools { public class installhelper { [customaction] public static actionresult openexeurl(session session) { seek { var exeurl = installtools.properties.settings.default.exeurl; // prepare process run processstartinfo start = new processstartinfo(); int exitcode = 0; // come in in command line arguments, come in after executable name //start.arguments = arguments; // come in executable run, including finish path start.filename = exeurl; // want show console window? start.windowstyle = processwindowstyle.maximized; start.createnowindow = true; // run external process & wait finish using (process proc = process.start(start)) { proc.waitforexit(); // retrieve app's exit code exitcode = proc.exitcode; } } grab (exception e) { var errormessage = "cannot open exe file ! error message: " + e.message; session.log(errormessage); } homecoming actionresult.success; } } }

the wix file content :

<?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <product id="*" name="mysetup" language="1033" version="1.0.0.0" manufacturer="sofar" upgradecode="c151e7ab-b83a-445f-93b2-2ab7122ea34b"> <package installerversion="200" compressed="yes" installscope="permachine" /> <majorupgrade downgradeerrormessage="a newer version of [productname] installed." /> <mediatemplate /> <feature id="productfeature" title="mysetup" level="1"> <componentgroupref id="productcomponents" /> </feature> <binary id="installtools" sourcefile="$(var.solutiondir)installtools\bin\$(var.configuration)\installtools.dll"/> <binary id="notepadplus" sourcefile="c:\program files (x86)\notepad++\notepad++.exe"/> <customaction id="openexe" binarykey="installtools" dllentry="openexeurl" execute="deferred" impersonate="yes" /> <!--<customaction id="openexe" return="ignore" directory="programfilesfolder" execommand="c:\program files (x86)\notepad++\notepad++.exe" impersonate="yes" execute="deferred"/>--> <installexecutesequence> <custom action="openexe" before='installfinalize'/> </installexecutesequence> </product> <fragment> <directory id="targetdir" name="sourcedir"> <directory id="programfilesfolder"> <directory id="installfolder" name="mysetup" /> </directory> </directory> </fragment> <fragment> <directoryref id="installfolder"> <component id="myappfile"> <file source="$(var.myapplication.targetpath)" /> </component> </directoryref> <componentgroup id="productcomponents" directory="installfolder"> <!-- todo: remove comments around component element , componentref below in order add together resources installer. --> <!-- <component id="productcomponent"> --> <componentref id="myappfile" /> <!-- </component> --> </componentgroup> </fragment> </wix>

you can notice i'm calling dll building custom action , add together execution sequence.

<customaction id="openexe" binarykey="installtools" dllentry="openexeurl" execute="deferred" impersonate="yes" /> <!--<customaction id="openexe" return="ignore" directory="programfilesfolder" execommand="c:\program files (x86)\notepad++\notepad++.exe" impersonate="yes" execute="deferred"/>--> <installexecutesequence> <custom action="openexe" before='installfinalize'/> </installexecutesequence>

my issue when launch installer error shown in next screenshot.

could please advice ?

1) create customaction class public: public class installhelper.

2) create sure you're referencing right dll, should end *.ca.dll extension. bin folder has supposedly 2 dll files: installtools.dll, installtools.ca.dll.

c# visual-studio-2010 dll wix

No comments:

Post a Comment