使用 .NET Core 和 Google 工作表 API 的 AWS Lambda
AWS Lambda using .NET Core and Google Sheets API
我正在编写一个使用 C# 运行时 (.NET Core) 的 AWS Lambda 函数的 Alexa 技能,并尝试使用他们的 [=23] 连接到 Google Sheet =].它在运行时抛出一个丢失的 DLL 异常:
The type initializer for 'System.Security.Cryptography.CngKeyLite' threw an exception.
at System.Security.Cryptography.CngKeyLite.ImportKeyBlob(String blobType, Byte[] keyBlob)
at System.Security.Cryptography.RSAImplementation.RSACng.ImportKeyBlob(Byte[] rsaBlob, Boolean includePrivate)
at System.Security.Cryptography.RSAImplementation.RSACng.ImportParameters(RSAParameters parameters)
at Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer.FromPrivateKey(String privateKey)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateServiceAccountCredentialFromParameters(JsonCredentialParameters credentialParameters)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateDefaultCredentialFromParameters(JsonCredentialParameters credentialParameters)
at AlexaProjLib.GoogleSheet.Connect()
at AlexaProj.Function.FunctionHandler(SkillRequest input, ILambdaContext context)
内部异常:
Unable to load DLL 'ncrypt.dll': The specified module could not be found.
代码:
var credential = GoogleCredential.FromJson(_googleSecret).CreateScoped(_scopes);
Service = new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = _applicationName,
});
我是 .NET Core 和 Lambda 的新手 - 如何正确引用丢失的 DLL?
尝试按照 this github forum 中提供的说明进行操作,因为其他用户也遇到过。
execute
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
instead of
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib /usr/local/lib
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib /usr/local/lib
if you receive "File exists" message ln -sf will do the magic..
ln -sf /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -sf /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
问题原来是我在 project.json 文件 (win10-x64) 中定义了一个 Windows 运行时,这导致了这些运行时错误(AWS Lambda 在 Amazon Linux).最终通过使用 dotnet lambda 包 编译并 运行,更多细节 .
我正在编写一个使用 C# 运行时 (.NET Core) 的 AWS Lambda 函数的 Alexa 技能,并尝试使用他们的 [=23] 连接到 Google Sheet =].它在运行时抛出一个丢失的 DLL 异常:
The type initializer for 'System.Security.Cryptography.CngKeyLite' threw an exception.
at System.Security.Cryptography.CngKeyLite.ImportKeyBlob(String blobType, Byte[] keyBlob)
at System.Security.Cryptography.RSAImplementation.RSACng.ImportKeyBlob(Byte[] rsaBlob, Boolean includePrivate)
at System.Security.Cryptography.RSAImplementation.RSACng.ImportParameters(RSAParameters parameters)
at Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer.FromPrivateKey(String privateKey)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateServiceAccountCredentialFromParameters(JsonCredentialParameters credentialParameters)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateDefaultCredentialFromParameters(JsonCredentialParameters credentialParameters)
at AlexaProjLib.GoogleSheet.Connect()
at AlexaProj.Function.FunctionHandler(SkillRequest input, ILambdaContext context)
内部异常:
Unable to load DLL 'ncrypt.dll': The specified module could not be found.
代码:
var credential = GoogleCredential.FromJson(_googleSecret).CreateScoped(_scopes);
Service = new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = _applicationName,
});
我是 .NET Core 和 Lambda 的新手 - 如何正确引用丢失的 DLL?
尝试按照 this github forum 中提供的说明进行操作,因为其他用户也遇到过。
execute
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
instead of
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib /usr/local/lib
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib /usr/local/lib
if you receive "File exists" message ln -sf will do the magic..
ln -sf /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -sf /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
问题原来是我在 project.json 文件 (win10-x64) 中定义了一个 Windows 运行时,这导致了这些运行时错误(AWS Lambda 在 Amazon Linux).最终通过使用 dotnet lambda 包 编译并 运行,更多细节