Repository navigation
Description
A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
inspect the InnerException's StackTrace property. System.Collections.ListDictionaryInternal type:System.TypeInitializationException at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x159\r\n at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x1c\r\n at System.Data.SqlClient.TdsParser..ctor(Boolean MARS, Boolean fAsynchronous) + 0x28\r\n at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) + 0x20f\r\n at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) + 0x29f\r\n at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken) + 0x432\r\n at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) + 0x541\r\n at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) + 0x8d\r\n at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) + 0x45f\r\n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) + 0xdb\r\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) + 0x428\r\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) + 0xc9\r\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) + 0x686\r\n at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) + 0x17d\r\n at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) + 0x39\r\n at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) + 0x1e3\r\n at System.Data.SqlClient.SqlConnection.Open() + 0xff\r\n at webapi_mes.baseframework.SqlHelper.Open() + 0x199",
Activity
lozn00 commentedon May 19, 2023
lozn00 commentedon May 19, 2023
why asp.net core need
Microsoft.Data.SqlClient?lozn00 commentedon May 19, 2023
i use dotnet is from C:\Program Files\dotnet
why not use aot is normal work ,but dotnet throw exception
dotnet publish -r win-x64 -c xxxxlozn00 commentedon May 19, 2023
i check the out dir ,sni.dll is with the exe at same dir, but why still throw sni.dll cannot load?


deug attach exe output information
lozn00 commentedon May 19, 2023
debug program , is
connection.Open();throwlozn00 commentedon May 19, 2023
lozn00 commentedon May 19, 2023
Because there was a problem with the code running after AOT was compiled, I deleted many 7.0 folders on the computer and uninstalled it, resulting in this problem that cannot be fixed regardless of whether it is reinstalled or not.
I found this problem after my computer was reinstalled, which led me to start researching whether it was a version problem, and then repeatedly uninstall and install .net.7.0, so I violently deleted many net7.0 folders on the computer, and uninstalled, resulting in this problem has not been repaired whether it is reinstalled or not.
fatal error LNK1123: Failed during conversion to COFF: Invalid or corrupted file
lozn00 commentedon May 19, 2023
the 8.0 error
#2278
Trying to uninstall the .NET 7.0 runtime got an error that was even more difficult for me to accept
#2281
jkotas commentedon May 19, 2023
The native AOT projects lives in http://github.com/dotnet/runtime now. Please open any issues http://github.com/dotnet/runtime. Also, include steps to reproduce the issue.
Note that SqlClient is not yet compatible with AOT and trimming. This is tracked by dotnet/SqlClient#1947.
lozn00 commentedon May 20, 2023
测试提及 dotnet/SqlClient#1947
lozn00 commentedon May 20, 2023
dotnet/SqlClient/issues#1947 test
lozn00 commentedon May 20, 2023
How should I reinstall the relevant environment?, I used Visual Studio to re-check 143 related C++ libraries, nothing worked, I also tried to re-download the dotnet package installation still has no effect, but I tested the demo mentioned on runtimelab, I 6.0 7.0 net compiled this simple demo is no problem @jkotas
lozn00 commentedon May 20, 2023
clear bin obj Folder? Succeeded again, but again this problem arises because I currently have 7.0.5 installed again, I think 7.0.5 has some bugs, is not compatible
dotnet/runtime#86493
#dotnet/runtime#86493
jkotas commentedon May 20, 2023
Can you please try to publish a small project that opens SqlClient connection with native aot:
dotnet new consoledotnet add package System.Datadotnet publish /p:PublishAot=trueDoes the native AOT binary fail to sni.dll on your machine?
lozn00 commentedon May 20, 2023
我现在测试demo是正常的,但是我还要确认下现在真实项目是什么情况,为了解决这些问题,我升级 或者降级得到了不同的错误,8.0的aot错误更为严重
I am currently testing the demo as normal, but I also need to confirm the actual project situation. In order to address these issues, I upgraded or downgraded .net version and got different errors. The 8.0 AOT error is even more severe
https://github.com/qssq1/aotest
lozn00 commentedon May 20, 2023
I just uninstalled 7.0.5 and 8.0 which caused this annoying error again
sproj] VTRES : fatal error CVT1103: 无法读取文件 [D:\dev\company_project\webapi\webapi_mes\webapi_mes.csproj]
LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 [D:\dev\company_project\webapi\webapi_mes\webapi_mes.csproj]
C:\Program Files\dotnet\sdk\7.0.302\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets(350,5): err
or MSB3073: 命令“"D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\link.
exe" @"obj\YTLSX_R\net7.0\win-x64\native\link.rsp"”已退出,代码为 1123。 [D:\dev\company_project\webapi\webapi_mes\webapi_mes.c
sproj]
https://github.com/qssq1/aotest
But this little demo is normal and compiles AOT 6.0 and 7.0 normally
lozn00 commentedon May 20, 2023
I think I upgrade to 7.0.5 will get SQL client error, upgrade to 8.0 will get swagger error, this is the result of my previous test, 8.0 config manager I changed to write files directly, but there are more errors waiting for me to solve, I have to downgrade, and in the case of 8.0 I did not do AOT compilation, just run with Visual Studio and got that error
lozn00 commentedon May 20, 2023
So I think what I can do at the moment is downgrading below 7.0.5 can solve more problems, but my computer in the company seems to be unable to fix CVTRES: fatal error CVT1103: Error, I have reinstalled these nets, those small demos can run normally, my home computer compiles very slowly, but successfully makes the project not report errors, my company's computer was also used before the 7.0 lower version was also solved by me The error has been running stably for several months
lozn00 commentedon May 20, 2023
i just run
dotnet publish webapi_mes.csproj -r win-x64 -c XXX_Rlozn00 commentedon May 20, 2023
lozn00 commentedon May 20, 2023
Small demos are fine, but real projects are still this throw error
lozn00 commentedon May 20, 2023
small demo is work
lozn00 commentedon May 20, 2023
uninstall 8.0 dotnet-sdk-7.0.203-win-x64 (1) 7.0.5 all package ,delete all 7.0.5 folder
by dotnet --info show all 7.0.5 folder
这次没有出现编译错误了,sql 错误也没有出现了,因此问题就是7.0.5导致的
There were no compilation errors or SQL errors this time, so the problem was caused by 7.0.5
lozn00 commentedon May 20, 2023
Due to some errors in 7.0.5 and 8.0 that I cannot solve, I have to downgrade to 7.0.4. However, I am worried about the future and will definitely need to upgrade. How can I solve these problems in the future? For example, in 8.0, the swagger was abnormal
jkotas commentedon May 20, 2023
You need to pay attention to warnings like "Assembly 'System.Data.SqlClient' produced trim warnings.". These warnings tell you that the code is not trimming or AOT compatible, and it can break unexpectedly.
There is no trimming and AOT compatible replacement of swagger at this time.
lozn00 commentedon May 22, 2023
@jkotas Thank you. I noticed those compilation warnings, but because the previous version was able to run and the error this time is different from when I was using the previous. net7.0 version, I don't know how to modify rd.xml or source generation to solve this problem
lozn00 commentedon May 22, 2023
@jkotas Thank you. I noticed those compilation warnings, but because the previous version was able to run and the error this time is different from when I was using the previous. net7.0 version, I don't know how to modify rd.xml or source generation to solve this problem
lozn00 commentedon May 22, 2023
@jkotas Thank you. I noticed those compilation warnings, but because the previous version was able to run and the error this time is different from when I was using the previous. net7.0 version, I don't know how to modify rd.xml or source generation to solve this problem
lozn00 commentedon May 22, 2023