It's clear your catch handler is being called because of the EXCEPTION property 
being set. You're probably having an exception in the course of handling the 
exception. In general, having things that can throw exceptions in catch blocks 
(especially unreliable things such as File I/O access) is not best practice.

Try minimizing your catch handler to be nothing more than the set property for 
EXCEPTION and see if your results change. 
        
-----Original Message-----
From: John Cooper 
Sent: Wednesday, March 19, 2014 8:22 AM
To: General discussion about the WiX toolset.
Subject: Re: [WiX-users] Custom Action error Handling in Wix 3.7

1) Client side isn't going to give you very many details, but basically, the 
server is refusing to allow a connection.

2) The Persist Security Info attribute on your connection strings opens a 
truck-sized security hole in your application.  I would strongly recommend 
removing it.

3) This custom action does basically the same thing as one of mine, but it does 
too much.  I have separate custom actions for building, parsing, getting the 
server version, and validating the connection string.  Separating out in this 
manner will make it much, much easier to validate and debug.

--
John Merryweather Cooper
Build & Install Engineer - ESA
Jack Henry & Associates, Inc.®
Shawnee Mission, KS  66227
Office:  913-341-3434 x791011
jocoo...@jackhenry.com
www.jackhenry.com



-----Original Message-----
From: Alan Smith [mailto:the_red_baro...@hotmail.com]
Sent: Tuesday, March 18, 2014 9:38 PM
To: General discussion about the WiX toolset.
Subject: Re: [WiX-users] Custom Action error Handling in Wix 3.7

Pavan,

Error is a generic SQL Exception 

Property(C): EXCEPTIONDETAILS = System.Data.SqlClient.SqlException 
(0x80131904): Login failed for user 'Username_user'.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 
exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand 
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, 
TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean 
enlistOK)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo 
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer 
timeout, SqlConnection owningObject)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo 
serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection 
owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
   at 
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection 
owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, 
String newPassword, Boolean redirectedUserInstance)
   at 
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity 
identity, SqlConnectionString connectionOptions, Object providerInfo, String 
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   at 
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection 
owningConnection)
   at 
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection
 owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection 
owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection 
owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection 
owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection 
owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection 
outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at CustomActions.GetDBVersion(Session session) === Logging stopped: 
3/18/2014  15:51:54 ===

Regards,

> From: pavan.kond...@accelrys.com
> To: wix-users@lists.sourceforge.net
> Date: Tue, 18 Mar 2014 18:45:08 -0700
> Subject: Re: [WiX-users] Custom Action error Handling in Wix 3.7
> 
> Hi Alan,
> 
> Can you post the error message that you see in the log?
> 
> --Pavan
> 
> -----Original Message-----
> From: Alan Smith [mailto:the_red_baro...@hotmail.com]
> Sent: Tuesday, March 18, 2014 4:56 PM
> To: wix-users@lists.sourceforge.net
> Subject: [WiX-users] Custom Action error Handling in Wix 3.7
> 
> I think this is an issue with how I am implementing my custom action, but I 
> am looking for some assistance with an issue I have encountered.
> 
> I have built a number of C# (.NET 4) Custom Actions which all reside in a 
> single DLL file. I am able to call all of these actions successfully and the 
> processing logic runs as expected, unless an exception is encountered. 
> Whenever an exception is encountered the custom action fails causing the 
> whole installation to roll back without ever entering my catch block. I have 
> witnessed this behaviour with a number of the actions that are scheduled to 
> run during the UI sequence (immediate type 1 custom actions). The below 
> details are for a specific new action I am developing to try and A: Verify 
> correct connection details for a database and B: Retrieve a version number 
> from the database. I am not looking for assistance with the C# code itself, 
> but as to why the error handling is not firing when run via WiX.
> 
> Below is my scheduling and C# code. Can anyone provide an explanation as to 
> why the exception handling is not being called? I have vetted my code with my 
> .NET developer colleagues and they are at a loss to explain it as well. I 
> have even added in the explicit SQL Exception handling (my error handling 
> does not need to be this precise) with no affect.
> 
> Using WiX 3.7 with Visual Studio 2010.
> 
> C# Code:
>     [CustomAction]
>     public static ActionResult GetDBVersion(Session session)
>     {
>         try
>         {
>             session.Log("Begin retrieval of version number");
>             string inputConnString = session["INPUT_CONN_STRING"];
>             string dbConnectionString = "";
>             if (string.IsNullOrEmpty(inputConnString))
>             {
>                 string dataSource = session["INPUT_SQL_SERVER"];
>                 string DBName = session["INPUT_DB_NAME"];
>                 string User = session["INPUT_USER_NAME"];
>                 string Password = session["INPUT_PASSWORD"];
>                 if (!string.IsNullOrEmpty(dataSource) && 
> !string.IsNullOrEmpty(DBName) && !string.IsNullOrEmpty(User) && 
> !string.IsNullOrEmpty(Password))
>                 {
>                     dbConnectionString = String.Format("Data 
> Source={0};Initial Catalog={1};Persist Security Info=True;User 
> ID={2};Password={3};", dataSource.ToString().Replace("^", ","), DBName, User, 
> Password);
>                 }
>             }
>             else if (!string.IsNullOrWhiteSpace(inputConnString))
>             {
>                 dbConnectionString = inputConnString;
>             }
>             else
>             {
>                 throw new System.ApplicationException("Invalid Database 
> Connection String details");
>             }
>             string checkVersionCommand = "select Max(Replace(Version, 
> 'AppName', '')) from Version";
>             using (SqlConnection conn = new SqlConnection(dbConnectionString))
>             {
>                 conn.Open();
>                 using (SqlCommand cmd = new SqlCommand(checkVersionCommand, 
> conn))
>                 using (SqlDataReader rdr = cmd.ExecuteReader())
>                 {
>                     if (rdr.HasRows)
>                     {
>                         string databaseVersion = rdr.GetString(0);
>                         session["DATABASE_VERSION"] = databaseVersion;
>                     }
>                     else
>                     {
>                         session["DATABASE_VERSION"] = "NONE";
>                     }
>                 }
>             }
>         }
>         catch (System.Data.SqlClient.SqlException ex)
>         {
>             session.Log("ERROR in custom action GetDBVersion {0}",
>             ex.ToString());
>             session["EXCEPTIONDETAILS"] = ex.ToString();
>             string dir = session["CURRENTDIRECTORY"];
>             string filepath = dir + "\\Logs\\CustomAction.log";
>             File.AppendAllText(filepath, "ERROR in custom action GetDBVersion 
> - " + ex.ToString() + "\n");
>             session["DATABASE_VERSION"] = "ERROR";
>         }
>         catch (Exception ex)
>         {
>             session.Log("ERROR in custom action GetDBVersion-Generic {0}",
>             ex.ToString());
>             session["EXCEPTIONDETAILS"] = ex.ToString();
>             string dir = session["CURRENTDIRECTORY"];
>             string filepath = dir + "\\Logs\\CustomAction.log";
>             File.AppendAllText(filepath, "ERROR in custom action 
> GetDBVersion-Generic - " + ex.ToString() + "\n");
>             session["DATABASE_VERSION"] = "ERROR";
>         }
>         return ActionResult.Success;
>     }
> 
> CustomAction definition within WXS:
>     <CustomAction Id="A.GetDatabaseVersion" Return="check" 
> Execute="immediate" BinaryKey="CustomActions" DllEntry="GetDBVersion" 
> />
> 
> Custom Action Scheduling within UI Sequence
>     <UI>
>         <Dialog Id="SQLUserLoginDlg" Width="370" Height="270" 
> Title="!(loc.SQLUserLoginDlg_DialogTitle)">
>             <Control Id="Next" Type="PushButton" X="236" Y="243" 
> Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)">
> 
>                 
>                 <!-- Actions for Database version checking etc -->
>                 <Publish Event="DoAction" Value="A.SetInputSQLServer" 
> Order="10">1</Publish>
>                 <Publish Event="DoAction" Value="A.SetInputSQLDBName" 
> Order="10">1</Publish>
>                 <Publish Event="DoAction" Value="A.SetInputSQLUser" 
> Order="10">1</Publish>
>                 <Publish Event="DoAction" Value="A.SetInputSQLPassword" 
> Order="10">1</Publish>
>                 <Publish Event="DoAction" Value="A.GetDatabaseVersion" 
> Order="11">1</Publish> ...
> 
> Thanks.
> 
> Regards.
>                                         
> ----------------------------------------------------------------------
> -------- Learn Graph Databases - Download FREE O'Reilly Book "Graph 
> Databases" is the definitive new guide to graph databases and their 
> applications. Written by three acclaimed leaders in the field, this first 
> edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
> 
> 
> 
> ----------------------------------------------------------------------
> -------- Learn Graph Databases - Download FREE O'Reilly Book "Graph 
> Databases" is the definitive new guide to graph databases and their 
> applications. Written by three acclaimed leaders in the field, this 
> first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
                                          
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. Written by 
three acclaimed leaders in the field, this first edition is now available. 
Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users
NOTICE: This electronic mail message and any files transmitted with it are 
intended exclusively for the individual or entity to which it is addressed. The 
message, together with any attachment, may contain confidential and/or 
privileged information.
Any unauthorized review, use, printing, saving, copying, disclosure or 
distribution is strictly prohibited. If you have received this message in 
error, please immediately advise the sender by reply email and delete all 
copies.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. Written by 
three acclaimed leaders in the field, this first edition is now available. 
Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users
NOTICE: This electronic mail message and any files transmitted with it are 
intended
exclusively for the individual or entity to which it is addressed. The message, 
together with any attachment, may contain confidential and/or privileged 
information.
Any unauthorized review, use, printing, saving, copying, disclosure or 
distribution 
is strictly prohibited. If you have received this message in error, please 
immediately advise the sender by reply email and delete all copies.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to