Open genifycom opened 5 years ago
It reports Unable to load sni.dll
This is a similar problem as #5496 (that one hits it for clrcompression.dll). Can you try this workaround:
Publish the app as regular standalone app using
dotnet publish -c Release -r win-x64 /p:NativeCompilationDuringPublish=false
first, save sni.dll that got published, and then publish it again as native and copy sni.dll saved earlier next to the native .exe.
Thank you for the response. I followed your instructions and the sni.dll reference was resolved.
However the SQL access now reports "Column requires a valid DataType'. This indicates a different problem.
If I build with /p:NativeCompilationDuringPublish=false first and then take ALL of the dlls and place them in the same directory as the Native exe, I still get the same error. But If I run the exe in the full publish directory if works without the error.
Am I able to unpack the CoreRT generated exe?
Can you suggest any other debugging steps I can take.
Thank you.
Can you suggest any other debugging steps I can take.
Can you try these instructions? Setting a breakpoint on the RhThrowEx
method mentioned in the doc might give you more insights about the failure.
Thanks for the response. I can now see that it is failing on this call
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.getschema?view=netcore-2.1 Uses Assemblies: System.Data.dll, System.Data.SqlClient.dll
Cut down code is like this:
using (SqlConnection sourceConnection = new SqlConnection(_source_connection)) { sourceConnection.Open(); var source_schema = sourceConnection.GetSchema(); }
It reports "Column requires a valid DataType"
But I cannot seem to find out why.
Can you share the stack trace for the exception? I don't have a SQL server installed, but stack traces are usually as good as a local repro for these things.
Not very exciting
TestCoreRT.exe!RhThrowEx() Unknown TestCoreRT.exe!RhpThrowEx() Line 191 Unknown [External Code] TestCoreRT.exe!TestCoreRT_TestCoreRT_Program__Main() Line 22 Unknown [External Code] TestCoreRT.exe!wmain(int argc, wchar_t argv) Line 395 C++ [External Code]
This is using DotNet 2.1
csproj is:
`
` Code is:
` static void Main(string[] args) { Console.WriteLine("Hello World!");
using (SqlConnection sourceConnection = new SqlConnection(explicit_local_data))
{
sourceConnection.Open();
var source_schema = sourceConnection.GetSchema();
}
}
`
In the Debug
-> Options
menu of Visual Studio, can you remove the checkmark next to "Enable Just My Code" and try again?
That should show something more useful than just [External Code]
.
If I just run it from the command line here is what I get
Unhandled Exception: System.ArgumentException: Column requires a valid DataType.
at System.Data.DataColumn.set_DataType(Type) + 0xad
at System.Data.XSDSchema.SetProperties(Object, XmlAttribute[]) + 0x25b
at System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement, DataTable, Boolean) + 0xb50
at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle, DataTable, ArrayList, Boolean) + 0x490
at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType, DataTable, ArrayList, Boolean) + 0x961
at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement, XmlSchemaComplexType, Boolean) + 0x690
at System.Data.XSDSchema.HandleTable(XmlSchemaElement) + 0x136
at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement, Boolean) + 0x788
at System.Data.XSDSchema.LoadSchema(XmlSchemaSet, DataSet) + 0xe0b
at System.Data.DataSet.ReadXSDSchema(XmlReader, Boolean) + 0x304
at System.Data.DataSet.ReadXml(XmlReader, Boolean) + 0xaf9
at System.Data.DataSet.ReadXml(Stream) + 0x6d
at System.Data.ProviderBase.DbMetaDataFactory.LoadDataSetFromXml(Stream) + 0x81
at System.Data.ProviderBase.DbMetaDataFactory..ctor(Stream, String, String) + 0x60
at System.Data.SqlClient.SqlMetaDataFactory..ctor(Stream, String, String) + 0x2f
at System.Data.SqlClient.SqlConnectionFactory.CreateMetaDataFactory(DbConnectionInternal, Boolean&) + 0xcb
at System.Data.ProviderBase.DbConnectionFactory.GetMetaDataFactory(DbConnectionPoolGroup, DbConnectionInternal) + 0x6c
at System.Data.ProviderBase.DbConnectionInternal.GetSchema(DbConnectionFactory, DbConnectionPoolGroup, DbConnection, String, String[]) + 0x3b
at System.Data.SqlClient.SqlConnection.GetSchema(String, String[]) + 0x84
at System.Data.SqlClient.SqlConnection.GetSchema() + 0x43
at TestCoreRT.Program.Main(String[]) + 0x93
at TestCoreRT!
Here is the call stack without enable just my code
TestCoreRT.exe!RhThrowEx() Unknown TestCoreRT.exe!RhpThrowEx() Line 191 Unknown TestCoreRT.exe!System_Data_Common_System_Data_DataColumnset_DataType() Line 491 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchemaSetProperties() Line 288 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchemaHandleElementColumn() Line 2450 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchema__HandleParticle() Line 936 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchemaHandleComplexType() Line 1118 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchemaInstantiateTable() Line 1625 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchema__HandleTable() Line 2836 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchemaHandleDataSet() Line 2637 Unknown TestCoreRT.exe!System_Data_Common_System_Data_XSDSchemaLoadSchema_0() Line 792 Unknown TestCoreRT.exe!System_Data_Common_System_Data_DataSetReadXSDSchema() Line 1780 Unknown TestCoreRT.exe!System_Data_Common_System_Data_DataSetReadXml_0() Line 2088 Unknown TestCoreRT.exe!System_Data_Common_System_Data_DataSetReadXml_1() Line 2250 Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_ProviderBase_DbMetaDataFactoryLoadDataSetFromXml() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_ProviderBase_DbMetaDataFactory___ctor() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_SqlClientSqlMetaDataFactoryctor() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_SqlClient_SqlConnectionFactoryCreateMetaDataFactory() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_ProviderBase_DbConnectionFactoryGetMetaDataFactory() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_ProviderBase_DbConnectionInternalGetSchema() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_SqlClient_SqlConnectionGetSchema_1() Unknown TestCoreRT.exe!System_Data_SqlClient_System_Data_SqlClient_SqlConnectionGetSchema() Unknown TestCoreRT.exe!TestCoreRT_TestCoreRT_ProgramMain() Line 23 Unknown TestCoreRT.exe!TestCoreRTModuleMainMethodWrapper() Unknown TestCoreRT.exe!TestCoreRTModuleStartupCodeMain() Unknown TestCoreRT.exe!wmain(int argc, wchar_t argv) Line 395 C++ [Inline Frame] TestCoreRT.exe!invoke_main() Line 90 C++ TestCoreRT.exe!__scrt_common_main_seh() Line 288 C++ kernel32.dll!00007fff69503034() Unknown ntdll.dll!00007fff6a673691() Unknown
Thanks! I see this is trying to do something with an XSD schema file embedded in System.Data.SqlClient. The schame refers to several types that we probably didn't compile.
Can you try adding an RD.XML file to your project with the following content:
<Directives>
<Application>
<Assembly Name="System.Data.Common" Dynamic="Required All" />
<Assembly Name="System.Data.SqlClient" Dynamic="Required All" />
<Assembly Name="System.Data" />
</Application>
</Directives>
This is a sample of how to refer to the RD.XML from your project file:
Not 100% sure it will help, but it's worth a shot...
Yes! That worked for my simple test case (Just GetSchema). Thank you.
In my regular case I get this stack trace
---> System.TypeLoadException: The type 'System.String' cannot be found in assembly 'Microsoft.SqlServer.SqlEnum, Version=15.2.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.
at Internal.Reflection.Core.Execution.ExecutionDomain.<>c__DisplayClass3_0.
Any ideas on how to fix that one?
Thank you for your help on this.
I think that error should by fixable by adding <Assembly Name="mscorlib" />
to the RD.XML file.
Thanks Michal, I tried that but no change. Same stack trace.
A CoreRT built console app that uses System.Data.SqlClient does not make a connection to the database.
It reports Unable to load sni.dll
I try to using .NET Core 3.0.100 with ReadyToRun, it's work
please checkout here https://github.com/ifew/netcore3-readytorun-dapper
A CoreRT built console app that uses System.Data.SqlClient does not make a connection to the database.
It reports Unable to load sni.dll