В этом CustomAction есть простое соединение с базой данных Oracle. Я должен получить имена из таблицы. Проблема в том, что он не может подключиться. Факт в последовательности установки, я получил другое пользовательское действие, которое устанавливает соединение, и оно работает.
Вот код
using System;
using System.Collections.Generic;
using System.Text;
using WixToolset.Dtf.WindowsInstaller;
using Oracle.DataAccess.Client;
using System.IO;
using System.Data.SqlClient;
using System.Web;
namespace CustomAction1
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
string ConnectionString = "User Id=NO;Password=NO;Data Source=NO";
string properties;
using (OracleConnection con = new OracleConnection(ConnectionString))
{
con.Open();
using (OracleCommand retreive = new OracleCommand("select TABLE_EL from TABLE", con))
using (OracleDataReader rd = retreive.ExecuteReader())
{
properties = null;
int i = 0;
while (rd.Read())
{
if (properties != null)
properties = properties + "," + rd.GetString(0).Trim();
else
properties = rd.GetString(0).Trim();
i++;
}
}
}
session["ELENCODITTE"] = properties;
return ActionResult.Success;
}
}
Вот исключение, выданное
Exception thrown by custom action:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.RegAndConfigRdr' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section startup. (C:\Users\davanzo\AppData\Local\Temp\6\MSI9D8D.tmp-\CustomAction.config line 3)
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at Oracle.DataAccess.Client.RegAndConfigRdr..cctor()
--- End of inner exception stack trace ---
at Oracle.DataAccess.Client.RegAndConfigRdr.ReadEntriesForRegistryAndConfig()
at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleConnection..cctor()
--- End of inner exception stack trace ---
at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
at CustomAction1.CustomActions.CustomAction1(Session session) in C:\Users\davanzo\source\repos\FetchDitte\FetchDitte\CustomAction.cs:line 20
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at WixToolset.Dtf.WindowsInstaller.CustomActionProxy.InvokeCustomAction(Int32 sessionHandle, String entryPoint, IntPtr remotingDelegatePtr)
CustomAction FetchDitte.CA.dll_1 returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 15:31:25: FetchDitte.CA.dll_1. Return value 3.
MSI (c) (4C:28) [15:31:25:353]: Doing action: FatalError
Action 15:31:25: FatalError.
Action start 15:31:25: FatalError.