我有一个小样本项目(https://github.com/Agitto/SqlClientProblem)。
它在windows上运行良好(dnx-corecrl-win-x64.1.0.0-rc1-15838运行时)。但如果我在ubuntu(dnx-corecrl-linux-x64.1.0.0-rc1-15838)上运行它,它将异常地落在下面。可能有问题?
System.IO.FileNotFoundException:无法加载文件或程序集“system.data.sqlclient,version=4.0.0.0,culture=neutral,publickeytoken=b03f5f7f11d50a3A”或其依赖项之一。系统找不到指定的文件。

File name: 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load the specified file.
File name: 'System.Data.SqlClient'
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at ConsoleApp3.Program.Main(String[] args)
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 Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)
System.IO.FileNotFoundException: Could not load the specified file.
File name: 'System.Data.SqlClient'
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)

最佳答案

您应该将此引用添加到project.json
“system.data.sqlclient”:“4.0.0-beta-23516”

关于c# - 在Linux-coreclr-rc1下使用System.Data.SqlClient,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33350449/

10-12 14:44