[英]WiX Custom Action Ends Prematurely
關於該主題有多個問題,我嘗試了所有解決方案,但對我沒有任何幫助。
問題在於它在安裝了Visual Studio的計算機上“可以”工作,但在其他PC上卻無法工作..這使得調試非常困難。
定制操作代碼為:
[CustomAction]
public static ActionResult EnumerateSqlServers(Session session)
{
MessageBox.Show("start EnumerateSQLServers"); // the message is not showing.
ActionResult result;
DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
DataRow[] rows = dt.Select(string.Empty);//, "IsLocal desc, Name asc");
result = EnumSqlServersIntoComboBox(session, rows);
return result;
}
日志文件顯示:
MSI (c) (2C:1C) [11:16:42:338]: Doing action: EnumerateSqlServersAction
Action 11:16:42: EnumerateSqlServersAction.
Action start 11:16:42: EnumerateSqlServersAction.
MSI (c) (2C:34) [11:16:42:385]: Invoking remote custom action. DLL: C:\Users\Test\AppData\Local\Temp\MSI9328.tmp, Entrypoint: EnumerateSqlServers
MSI (c) (2C:E8) [11:16:42:385]: Cloaking enabled.
MSI (c) (2C:E8) [11:16:42:385]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (2C:E8) [11:16:42:385]: Connected to service for CA interface.
Action ended 11:16:42: EnumerateSqlServersAction. Return value 3.
DEBUG: Error 2896: Executing action EnumerateSqlServersAction failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: EnumerateSqlServersAction, ,
Action ended 11:16:42: WelcomeDlg. Return value 3.
MSI (c) (2C:44) [11:16:42:635]: Doing action: FatalError
Action 11:16:42: FatalError.
Action start 11:16:42: FatalError.
Action 11:16:42: FatalError. Dialog created
Action ended 11:16:43: FatalError. Return value 2.
Action ended 11:16:43: INSTALL. Return value 3.
MSI (c) (2C:44) [11:16:43:370]: Destroying RemoteAPI object.
MSI (c) (2C:E8) [11:16:43:385]: Custom Action Manager thread ending.
我確實嘗試過這樣的空動作:
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
MessageBox.Show("");
return ActionResult.Success;
}
該動作有效! 它顯示一個空的消息框。
編輯:經過大量的測試,我發現問題所在是enumSQLServer,當我對此行進行注釋時。
SmoApplication.EnumAvailableSqlServers(false);
使用詳細(/ l * v)設置記錄安裝程序。 我希望看到更多包括.NET錯誤堆棧跟蹤的信息。 您可能會丟失Visual Studio計算機上的依賴項,而不是干凈的測試計算機上的依賴項。
最可能丟失的依賴項是Microsoft.SqlServer.Smo.dll。 在您的自定義操作項目中,檢查此引用是否設置為CopyLocal = true,如果未設置,則進行設置。
您是否已經嘗試過以提升的權限運行安裝程序(右鍵單擊安裝程序並選擇“以管理員身份運行”)?
據我所知,SmoApplication.EnumAvailableSqlServers(false)需要提升的權限。
還要在.wxs文件的“產品”節點中檢查對自定義操作的定義。
以下定義應該起作用:
<CustomAction Id="EnumerateSqlServers" BinaryKey="YOUR BINARY KEY" DllEntry="EnumerateSqlServers" Execute="immediate" Return="check"/>
還可以嘗試以下方法進行測試:
<InstallUISequence> <Custom Action="EnumerateSqlServers" Before="ExecuteAction" Overridable="yes">NOT Installed</Custom> </InstallUISequence>
就我而言,這是在安裝和卸載過程中發生的。
我們正在做的是加密作為參數傳遞的連接字符串。
安裝
失敗是因為我無權訪問仍在解決的已安裝配置文件。 我希望WiX易於使用或有更好的文檔。
卸載
因為我們沒有執行“自定義操作”的任何條件,所以它也正在卸載期間運行,並且在嘗試加載不再存在的配置文件時失敗。
解決方案:使用未NOT Installed AND NOT REMOVE
。 如何僅在安裝(而非卸載)中執行自定義操作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.