Closed dongfengxin closed 6 months ago
Find another
Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'Microsoft.Data.SqlClient.SNI.dll' or one of its dependencies: The specified module could not be found.
at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x6f
at Internal.Runtime.CompilerHelpers.InteropHelpers.FixupModuleCell(InteropHelpers.ModuleFixupCell) + 0xfd
at Internal.Runtime.CompilerHelpers.InteropHelpers.ResolvePInvokeSlow(InteropHelpers.MethodFixupCell) + 0x2f
at Microsoft.Data.SqlClient.SNINativeMethodWrapper.UnmanagedIsTokenRestricted(IntPtr, Boolean&) + 0x31
at Microsoft.Data.Win32NativeMethods.IsTokenRestrictedWrapper(IntPtr) + 0x19
at Microsoft.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrentNative() + 0xb1
at Microsoft.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory) + 0x53
at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection, DbConnectionPoolGroup) + 0xa3
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection, TaskCompletionSource1, DbConnectionOptions, DbConnectionInternal, DbConnectionInternal&) + 0x5c at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection, DbConnectionFactory, TaskCompletionSource
1, DbConnectionOptions) + 0x118
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1, SqlConnectionOverrides) + 0x1a9
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides) + 0x1ed
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.
Author: | dongfengxin |
---|---|
Assignees: | - |
Labels: | `untriaged`, `area-NativeAOT-coreclr`, `needs-area-label` |
Milestone: | - |
Could you please share complete repro steps to reproduce the problem? (.csproj + .cs)
This issue has been marked needs-author-action
and may be missing some important information.
Solution Structure
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ConsoleApp1 { public class ConfigureManager { public IConfiguration iConfiguration { get; set; }
private IServiceCollection iServices;
public T GetConfiguration<T>(string Key) where T : class, new()
{
var t = iConfiguration.GetSection(Key).Get<T>();
return t!;
}
public T GetConfiguration<T>() where T : class, new()
{
var t = iConfiguration.GetSection(typeof(T).Namespace + ":" + typeof(T).Name).Get<T>();
return t!;
}
public T GetConfiguration<T>(string Key, bool Candidate) where T : class, new() //Need To Be Update To Remove The Candidate para
{
var t = iServices.Configure<T>("From Json Configuration", Options => iConfiguration.GetSection(Key).Get<T>()).BuildServiceProvider().GetService<IOptionsSnapshot<T>>();
return t!.Value;
}
public void SetConfiguration(string Key, object Value)
{
iConfiguration[Key] = Value.ToString();
}
public void SetConfiguration<T>(T Value)
{
var PI = typeof(T).GetProperties();
var RootKey = typeof(T).Namespace + ":" + typeof(T).Name;
int i = 0;
foreach (var pi in PI)
{
var Key = RootKey + ":" + pi.Name;
iConfiguration[Key] = PI[i].GetValue(Value, null)!.ToString();
i++;
}
}
public void SetConfiguration<T>(string Key, T Value, bool Candidate) where T : class, new() //Need To Be Update To Remove The Candidate para
{
iServices.Configure<T>("From Json Configuration", Options => iConfiguration[Key] = Value!.ToString()).BuildServiceProvider().GetService<IOptionsSnapshot<T>>();
}
}
}
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ConsoleApp1 { public class ProgressBarModeArgs { public ProgressBarModeArgs() { configuremanager = new ConfigureManager(); }
public ConfigureManager configuremanager { get; set; }
private string progressbarmode;
public string ProgressBarMode
{
get
{
progressbarmode = configuremanager.GetConfiguration<ProgressBarModeOptions>().ProgressBarMode!;
return progressbarmode;
}
set
{
configuremanager.SetConfiguration(new ProgressBarModeOptions { ProgressBarMode = value });
progressbarmode = value;
}
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ConsoleApp1 { public class ProgressBarModeOptions { public string? ProgressBarMode { get; set; } } }
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options;
namespace ConsoleApp1 { public class Program { static void Main(string[] args) { var progressbarmodeargs = new ProgressBarModeArgs(); Console.WriteLine("Hello, World!"); Console.WriteLine(progressbarmodeargs.ProgressBarMode); } } }
{ "ProgressBars.Models": { "ProgressBarModeOptions": { "ProgressBarMode": "Production" } } }
dotnet publish
works fine for me on this project. Does this project fail with the same error as you reported originally?
Your original error mentioned Microsoft.Data.SqlClient
, but this project does not reference Microsoft.Data.SqlClient
anywhere.
dotnet publish
works fine for me on this project. Does this project fail with the same error as you reported originally?Your original error mentioned
Microsoft.Data.SqlClient
, but this project does not referenceMicrosoft.Data.SqlClient
anywhere.
the above project is a demo which shows the problem , as you mentioned the problem doesn't happen again. and when I optimize it again, I got the error same like the above again.:
Unhandled Exception: System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property. ---> System.IO.FileNotFoundException: Could not find file 'Microsoft.Extensions.Configuration.Abstractions'. File name: 'Microsoft.Extensions.Configuration.Abstractions' at Internal.Runtime.TypeLoaderExceptionHelper.CreateFileNotFoundException(ExceptionStringID, String) + 0x43 at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowFileNotFoundException(ExceptionStringID, String) + 0x9 at Indexs.Models.IndexArgs.get_RiskMonitorID() + 0x15 at Indexs.Models.IndexArgs..ctor() + 0x3ce at Indexs.Models.IndexArgs.DefaultHolder..cctor() + 0x1c at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0xb9 --- End of inner exception stack trace --- at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0x14a at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnGCStaticBase(StaticClassConstructionContext*, Object) + 0xd
and when publish in the right click of the project , the publish action success, but when I publish the project with command dotnet publish ,there is no error message, but did not got the publish exe file and the folder bin\release\net8.0\publish\win-x64
when I publish the project with command dotnet publish ,there is no error message, but did not got the publish exe file
Could you please share the output of the dotnet publish
command?
Dereference of a possibly null reference. 16>Dereference of a possibly null reference. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Synchronously waiting on tasks or awaiters may cause deadlocks. Use await or JoinableTaskFactory.Run instead. (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD002.md) 16>Using member 'System.Exception.TargetSite.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Exception.TargetSite.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Exception.TargetSite.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Observe the awaitable result of this method call by awaiting it, assigning to a variable, or passing it to another method (https://github.com/Microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD110.md) 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 16>Using member 'System.Reflection.MethodBase.GetCurrentMethod()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed.
16>ILC: Method '[Services]Services.Models.UpdateModelArgs.get_UpdateModel()' will always throw because: Failed to load assembly 'Microsoft.Extensions.Configuration.Abstractions'
using dotnet publish command Error message:
MSBuild version 17.9.0-preview-23618-08+82d381eb2 for .NET Determining projects to restore... C:\Program Files\dotnet\sdk\8.0.200-preview.23624.5\NuGet.targets(169,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [D:\Solutions\NativeAOT\PublishNativeAOT\PublishNativeAOT.CLI.csproj] C:\Program Files\dotnet\sdk\8.0.200-preview.23624.5\NuGet.targets(169,5): error : The SSL connection could not be established, see inner exception. [D:\Solutions\NativeAOT\PublishNativeAOT\PublishNativeAOT.CLI.csproj] C:\Program Files\dotnet\sdk\8.0.200-preview.23624.5\NuGet.targets(169,5): error : Received an unexpected EOF or 0 bytes from the transport stream. [D:\Solutions\NativeAOT\PublishNativeAOT\PublishNativeAOT.CLI.csproj]
dotnet publish success, but right click the project to publish NativeAOT still not working. No matter , a success way have got!
when I publish the project with command dotnet publish ,there is no error message, but did not got the publish exe file
Could you please share the output of the
dotnet publish
command?
Thank you for your help, dotnet publish success, but right click the project to publish NativeAOT still not working. No matter , a success way have got!
right click the project to publish NativeAOT still not working
What does it do? Do you see any errors? Could you please share your VS publish profile for the project?
If the publish profile has "Target Runtime" set to portable
, you need to change it to win-x64
.
This issue has been marked needs-author-action
and may be missing some important information.
This issue has been automatically marked no-recent-activity
because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity
.
This issue will now be closed since it had been marked no-recent-activity
but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Description
Publish NativeAOT Project with Configure Manager Got the follwing error
Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'Microsoft.Extensions.Configuration.Abstractions'. File name: 'Microsoft.Extensions.Configuration.Abstractions' at Internal.Runtime.TypeLoaderExceptionHelper.CreateFileNotFoundException(ExceptionStringID, String) + 0x43 at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowFileNotFoundException(ExceptionStringID, String) + 0x9
Further more with the command : dotnet publish -r win-x64 did not got the published exe file, don't known why.
Reproduction Steps
Expected behavior
No Error
Actual behavior
Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'Microsoft.Extensions.Configuration.Abstractions'. File name: 'Microsoft.Extensions.Configuration.Abstractions' at Internal.Runtime.TypeLoaderExceptionHelper.CreateFileNotFoundException(ExceptionStringID, String) + 0x43 at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowFileNotFoundException(ExceptionStringID, String) + 0x9
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response