aws-sdk-net: SDK Calls Fail on Log4Net Dependency With XUnit and .Net Core
What is happening is the FallbackCredntialsFactory is trying to load up the credentials from Environment variables. When the EnvironmentVariablesAWSCredentials class executes it’s constructor it tries to get a Logger which then throws the exception posted below.
Easiest way to reproduce this issue is make a new .netcore lambda function with a xunit test. You can use the Amazon provided templates for visual studio 2017. Then try and execute this code var sns = new AmazonSimpleNotificationServiceClient() you will get an exception
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Boolean System.Reflection.Assembly.op_Equality(System.Reflection.Assembly, System.Reflection.Assembly)'.
at log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, Type type)
--- End of inner exception stack trace ---
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 Amazon.Runtime.Internal.Util.InternalLog4netLogger..ctor(Type declaringType) in E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util\Logger.Log4net.cs:line 147
at Amazon.Runtime.Internal.Util.Logger..ctor(Type type) in E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util\Logger.cs:line 46
at Amazon.Runtime.Internal.Util.Logger.GetLogger(Type type) in E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util\Logger.cs:line 111
at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor() in E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\_bcl+coreclr\EnvironmentVariablesAWSCredentials.cs:line 54
at Amazon.Runtime.FallbackCredentialsFactory.<>c.<Reset>b__8_1() in E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\FallbackCredentialsFactory.cs:line 53
at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) in E:\JenkinsWorkspaces\v3-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\FallbackCredentialsFactory.cs:line 113
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 25
It looks like the vstest team is working on a fix and I see that they have recently pushed a commit that disposes the assemblyresolver. I am still awaiting an official word that the fix is in production. For the time being to work around the error either