Npgsql3.1.9を使用していました
START RequestId: 147aefc2-c10f-11e6-b24b-6daefcf72be1 Version: $LATEST
Exception System.TypeInitializationException: The type initializer for 'Npgsql.TypeHandlerRegistry' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at Npgsql.TypeHandlerRegistry..cctor()
--- End of inner exception stack trace ---
at Npgsql.TypeHandlerRegistry.Setup(NpgsqlConnector connector, NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
at Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnection.OpenInternal()
at Seaside.Api.HelloWorld.Functions.<GetAsync>d__0.MoveNext()
END RequestId: 147aefc2-c10f-11e6-b24b-6daefcf72be1
REPORT RequestId: 147aefc2-c10f-11e6-b24b-6daefcf72be1 Duration: 96.22 ms Billed Duration: 100 ms Memory Size: 256 MB Max Memory Used: 31 MB
ネイティブの依存関係を解決することは、私たちが改善するために取り組んでいることです。 それまでの回避策として、aws-lambda-tools-defaults.jsonファイルに「additional-files」プロパティを追加して、ネイティブ解像度を強制することができます。 これを行うと、postgresqlデータベースに接続することができました。
...
"function-handler": "NpgsqlTest::NpgsqlTest.Function::FunctionHandler",
"additional-files": [
"runtimes/linux/lib/netstandard1.3/System.Net.NetworkInformation.dll"
]
}
ナイスワンノーム👍
私は同じ問題を抱えていますが、Macの.Netコアに問題があります。 Visual Studioまたはaws-lambda-toolsを使用しない場合、「additional-files」に相当するものはありますか?
Amazon.Lambda.Tools NuGetパッケージを使用してdotnet lambda deploy-functionを実行すると、Visual Studioが追加ファイルセクションを含めて行うのと同じように、 aws-lambda-tools-defaults.jsonファイルが読み取られます。
Macのユーザーをサポートするために、VisualStudioのすべての展開機能がdotnetCLIを介して利用できることを確認したかったのです。
この回答により、さらに多くの苦痛が軽減されました...ただし、VSを使用してパッケージ/アップロードをビルドせず、代わりに通常のcoreclrツール(つまり「dotnetpublish」)を使用している場合は、aws-lambda-tools-の設定に注意してください。 defaults.jsonは無視されるため、このファイルをパッケージディレクトリのルートに手動でコピーする必要があります。
dotnet publish
使用する代わりに、 dotnet lambda package
いずれかを使用することをお勧めします。 これは、Visual Studioで行うのと同じパッケージングを行いますが、dotnetCLIから行います。 dotnet lambda help
実行すると、NuGetパッケージAmazon.Lambda.Tools
を介してdotnetCLIに追加したコマンドの完全なリストを確認できます。
最も参考になるコメント
ネイティブの依存関係を解決することは、私たちが改善するために取り組んでいることです。 それまでの回避策として、aws-lambda-tools-defaults.jsonファイルに「additional-files」プロパティを追加して、ネイティブ解像度を強制することができます。 これを行うと、postgresqlデータベースに接続することができました。