{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/30518","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/30518/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/30518/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/30518/events","html_url":"https://github.com/dotnet/corefx/issues/30518","id":333764587,"node_id":"MDU6SXNzdWUzMzM3NjQ1ODc=","number":30518,"title":"The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception.: TypeInitializationException","user":{"login":"ajcvickers","id":1430078,"node_id":"MDQ6VXNlcjE0MzAwNzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1430078?v=4","gravatar_id":"","url":"https://api.github.com/users/ajcvickers","html_url":"https://github.com/ajcvickers","followers_url":"https://api.github.com/users/ajcvickers/followers","following_url":"https://api.github.com/users/ajcvickers/following{/other_user}","gists_url":"https://api.github.com/users/ajcvickers/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcvickers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcvickers/subscriptions","organizations_url":"https://api.github.com/users/ajcvickers/orgs","repos_url":"https://api.github.com/users/ajcvickers/repos","events_url":"https://api.github.com/users/ajcvickers/events{/privacy}","received_events_url":"https://api.github.com/users/ajcvickers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-19T17:18:23Z","updated_at":"2018-06-19T17:18:23Z","closed_at":null,"author_association":"MEMBER","body":"Originally posted as https://github.com/aspnet/EntityFrameworkCore/issues/12386 by \t@hounddog22030\r\n\r\nMoved here because stack trace indicates it is a problem loading sni.dll from SqlClient package and csproj indicates that package references are correct.\r\n\r\n---\r\n\r\nWe have been using EF Core 1.0 and 2.0 on AWS Lambda\r\n\r\nWith no other code changes, updating to EF Core 2.1 is throwing the exception \"The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception.: TypeInitializationException\"\r\n\r\nException message: \"The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception.: TypeInitializationException\"\r\nStack trace:\r\n\r\nThe type initializer for 'System.Data.SqlClient.TdsParser' threw an exception.: TypeInitializationException\r\nat System.Data.SqlClient.TdsParser..ctor(Boolean MARS, Boolean fAsynchronous)\r\nat System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)\r\nat System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)\r\nat 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)\r\nat System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)\r\nat System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)\r\nat System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\nat System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\r\nat System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\nat System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\nat System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\nat System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\nat System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\r\nat System.Data.SqlClient.SqlConnection.Open()\r\nat Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)\r\nat Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)\r\nat Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)\r\nat Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)\r\nat Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()\r\nat System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\r\nat Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__17`2.MoveNext()\r\nat Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()\r\nat Functions.EfCoreAwsLambdaReproduce.MyFunction(ILambdaContext lambdaContext) in /codebuild/output/src963058259/src/Functions/EFCoreAWSLambdaReproduce.cs:line 41\r\n\r\nat System.Data.SqlClient.TdsParserStateObjectFactory.get_EncryptionOptions()\r\nat System.Data.SqlClient.TdsParser..cctor()\r\nUnable to load DLL 'sni.dll': The specified module or one of its dependencies could not be found.\r\n(Exception from HRESULT: 0x8007007E): DllNotFoundException\r\nat System.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo)\r\nat System.Data.SqlClient.SNILoadHandle..ctor()\r\nat System.Data.SqlClient.SNILoadHandle..cctor()\r\n\r\n\r\n### Steps to reproduce\r\nI created the simplest example\r\n1. Create the following function with embedded classes\r\n2. Update server/database/password\r\n3. Deploy to AWS Lambda\r\n4. Execute function\r\n\r\n```c#\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.ComponentModel.DataAnnotations;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing Amazon.Lambda.Core;\r\nusing Bisque.Lambda;\r\nusing Bisque.Serverless;\r\nusing Microsoft.EntityFrameworkCore;\r\n\r\nnamespace Functions\r\n{\r\n    public class EfCoreAwsLambdaReproduce\r\n    {\r\n        public class MyEntity\r\n        {\r\n            [Key]\r\n            public Guid MyId { get; set; }\r\n            public string MyValue { get; set; }\r\n        }\r\n        public class MyContext : DbContext\r\n        {\r\n            public DbSet<MyEntity> MyEntities { get; set; }\r\n            protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\r\n            {\r\n                base.OnConfiguring(optionsBuilder);\r\n                if (!optionsBuilder.IsConfigured)\r\n                {\r\n                    optionsBuilder.UseSqlServer($\"Server=myserver;Database=MyDatabase;MultipleActiveResultSets=True;User Id=masterusername;Password=mypassword;Trusted_Connection=false\");\r\n                }\r\n            }\r\n        }\r\n\r\n        [FunctionType(typeof(Function))]\r\n        [ServerlessFunction.PolicyAttribute(\"AWSLambdaVPCAccessExecutionRole\")]\r\n        public void MyFunction(ILambdaContext lambdaContext)\r\n        {\r\n            using (var dataContext = new MyContext())\r\n            {\r\n                lambdaContext.Logger.LogLine(\"foreach (MyEntity dataContextMyEntity in dataContext.MyEntities.Where(x=>x.MyValue.ToString().Contains(4)))\");\r\n                foreach (MyEntity dataContextMyEntity in dataContext.MyEntities.Where(x=>x.MyValue.ToString().Contains(\"4\")))\r\n                {\r\n                    lambdaContext.Logger.LogLine(dataContextMyEntity.MyId.ToString());\r\n                }\r\n                lambdaContext.Logger.LogLine(\"lambdaContext.Logger.LogLine(dataContext.MyEntities.Max(d => d.MyValue));\");\r\n                lambdaContext.Logger.LogLine(dataContext.MyEntities.Max(d => d.MyValue));\r\n\r\n\r\n            }\r\n        }\r\n\r\n\r\n    }\r\n}\r\n```\r\n\r\n### Further technical details\r\nEF Core version: 2.1.0\r\nDatabase Provider: Microsoft.EntityFrameworkCore.SqlServer\r\nOperating system:  AWS Lambda (Ubuntu?)\r\n\r\n"}}
{"actor":{"display_login":"ajcvickers"}}