C#自定义操作出错。有人知道这个错误吗?

C#自定义操作出错。有人知道这个错误吗?,c#,oracle,windows-installer,advanced-installer,C#,Oracle,Windows Installer,Advanced Installer,在这个CustomAction中,有一个到Oracle数据库的简单连接。 我得从一张桌子上检索名字。问题是它无法连接。事实上,在安装序列中,我得到了另一个自定义操作,该操作可以进行连接,并且可以正常工作 这是密码 using System; using System.Collections.Generic; using System.Text; using WixToolset.Dtf.WindowsInstaller; using Oracle.DataAccess.Client; using

在这个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.

解释就在错误本身中: System.Configuration.ConfigurationErrorsException:无法识别的配置节启动。
我认为您忘记在配置文件的configSections中添加正确的设置,该设置告诉框架如何处理自定义节的配置。

通过安装nuget软件包Oracle.ManagedDataAccess来解决此问题

这似乎是问题的根源:“System.Configuration.ConfigurationErrorsException:无法识别的配置节启动。(C:\Users\davanzo\AppData\Local\Temp\6\MSI9D8D.tmp-\CustomAction.config第3行)”-在
CustomAction.config
文件中有什么?''我得到了另一个具有完全相同配置文件的自定义操作,并且可以正常工作。我认为问题出在应用程序的app.config中,而不是CustomAction.config文件。最初没有app.config文件,我从另一个CustomAction复制粘贴的表单,但它好像没认出什么。如何将该配置文件附加到项目?请确保将App.config文件复制到输出文件夹。您可以在解决方案资源管理器中检查文件的属性。找到解决方案后,我必须安装Oracle.ManagedDataAccess nuget包。