正在使用 Npgsql 3.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 时,是否有等效于“附加文件”的内容?
如果您使用Amazon.Lambda.Tools NuGet 包进行部署,那么当您执行dotnet lambda deploy-function 时,它将读取aws-lambda-tools-defaults.json文件,就像 Visual Studio 所做的包括附加文件部分一样。
我们希望确保 Visual Studio 中的所有部署功能都可以通过 dotnet CLI 使用,以支持 Mac 上的用户。
这个答案为我节省了很多额外的痛苦……但是值得注意的是,如果您不使用 VS 来构建包/上传,而是使用常规的 coreclr 工具(即“dotnet 发布”),则 aws-lambda-tools- 中的任何设置- defaults.json 被忽略,因此需要手动将此文件复制到包目录的根目录。
我建议不要使用dotnet publish
使用dotnet lambda package
。 这将执行与我们在 Visual Studio 中所做的相同的打包,但来自 dotnet CLI。 您可以通过执行dotnet lambda help
查看我们通过 NuGet 包Amazon.Lambda.Tools
添加到 dotnet CLI 的命令的完整列表
最有用的评论
解决本机依赖项是我们正在努力改进的工作。 作为解决方法,您可以在 aws-lambda-tools-defaults.json 文件中添加“additional-files”属性,这将强制使用本机分辨率。 完成此操作后,我就能够连接到 postgresql 数据库。