winform sqlserver vs2026 aot 命令行发布后, 提示 返回

SqlSugar 沟通中
1 525
该叫什么 kk 发布于2025/12/23
悬赏:0 飞吻

] 初始化错误: 中文提示 :  连接数据库过程中发生错误,检查服务器是否正常连接字符串是否正确,错误信息:A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.DbType="SqlServer";ConfigId="".

English Message : Connection open error . A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.DbType="SqlServer";ConfigId="" 



        public AppFrmMain()

        {

            InitializeComponent();


            StaticConfig.EnableAot = true;

            InitializeTrayIcon();

            InitializeDicomEnvironment();

           

        }


internal SqlSugarUtil()

{


        

        dbContext = new SqlSugarClient(new ConnectionConfig

        {

            ConnectionString = AppConfig.ConnectionString,

            DbType = SqlSugar.DbType.SqlServer,

            IsAutoCloseConnection = true

        });

        LogDbCommandInterceptor.Register(dbContext); // 只注册一次


    }


<PropertyGroup>

<OutputType>WinExe</OutputType>

<TargetFramework>net10.0-windows</TargetFramework>

<RootNamespace>CStoreSCPForm</RootNamespace>

<Nullable>enable</Nullable>

<UseWindowsForms>true</UseWindowsForms>

<ImplicitUsings>enable</ImplicitUsings>

<BaseOutputPath>Y:\Test</BaseOutputPath>

<Configurations>Debug;Release;Publish</Configurations>

<InvariantGlobalization>false</InvariantGlobalization>

</PropertyGroup>




热忱回答1