Getting Conflict error for Amazon.RegionEndpoint with Sagemaker - c#

I have created an applicataion in c#, where I need to put some data on S3 bucket, and to Invoke AWS sagemaker APIs.
Since the same Amazon.RegionEndPoint class exists in both the references, it is giving below error.
The type 'RegionEndpoint' exists in both 'AWSSDK.Core,
Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604' and
'AWSSDK, Version=2.3.55.2
Basically I am trying to upload files on AWS S3, following code I have used.
AmazonS3Client s3Client = new AmazonS3Client(_AWS_ACCESS_KEY_ID, _AWS_SECRETE_ACCESS_KEY, Amazon.RegionEndpoint.USEast2);
PutObjectRequest request = new PutObjectRequest
{
BucketName = _BucketName,
Key = i_sDestFileName,
FilePath = i_sSourceFilePath,
ContentType = "text/plain"
};
s3Client.PutObject(request);
It is working fine on a single application, but when I integrated code with Sagemaker API invokation, the conflict occurs for Amazon.RegionEndpoint.USEast2.

Don't use AWSSDK package along with AWSSDK.Core. Remove it using the package manager and add your service-specific packages, for example, AWSSDK.S3 or AWSSDK.EC2 .
AWSSDK.Core is a new one with .NET core support and with that you need to install service-specific packages, while the older AWSSDK is a single package for all services. Below is the description of the older AWSSDK package from nuget:
This is the previous version 2 generation of the AWS SDK for .NET. The new version 3 of the AWS SDK for .NET uses separate packages for each service. For example Amazon S3 is in the AWSSDK.S3 package, Amazon SQS is in AWSSDK.SQS and Amazon DynamnoDB is in AWSSDK.DynamoDBv2.
Once you remove the older one and use the specific packages, the conflict will be resolved. But, note that there may be other errors then, as the constructs have changed slightly but are obvious/simple to fix. On the positive side, you get the async versions. ;)
--
// Noticed a comment from #Gerry-coll, above, on the main question, also mentions this. Leaving a detailed answer for others who bump into this issue even now.

It looks like you have two different versions of the AWS SDK installed, one much older than the other. I'd look to SO questions like Where does error CS0433 "Type 'X' already exists in both A.dll and B.dll " come from? for advice on resolving the conflict.

Consider moving your region details to of config file and access it from there. https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-region-selection.html

Related

Using Firestore with Azure Functions V2 (C#)

I am trying to use Firestore with Azure Functions, but I'm getting the following error:
System.Private.CoreLib: Exception while executing function:
HelloWorld. Grpc.Auth: Could not load type 'Grpc.Core.CallCredentials'
from assembly 'Grpc.Core.Api, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=d754f35622e28bad'.
I tried to use the steps from this question:
Grpc.Auth: Could not load type 'Grpc.Core.CallCredentials' from assembly 'Grpc.Core.Api'
however, it's related to the Language APIs, and the solution doesn't work for Firestore.
I tried changing the version of Grpc.Auth to 1.19.0, but this version doesn't appear to be supported by Firestore 1.0.0.
If I remove Firestore from the project and use grps.Auth 1.19.0 to initialize the Credentials object - this works. But the object isn't compatible with Firestore.
I also tried the PostBuild/PostPublish commands described in that question, but the commands fail to execute.
Before trying to use Firestore with Azure Functions, I successfully managed to use it with a .NET Core Web API project, but I'm struggling with Azure Functions and would appreciate any help.
It seems that it is a bug in Azure Functions and you could refer to this issue to track it.
If you update the cli directory to contain the relevant files from Grpc.Core and Grpc.Core.Api, and update func.deps.json accordingly, it all works - including Google.Cloud.Firestore.
So basically, this is a problem for any function needing to use a version of Grpc.Core later than the one embedded in the CLI application.

Did not find reference matching RestoreAssemblyResources AssemblyName metadata 'Xamarin.Firebase.Messaging'

I want to use Push Notifications in my Xamarin application.
I used the following namespaces
using Microsoft.AppCenter;
using Microsoft.AppCenter.Push;
but I got the following error
Did not find reference matching RestoreAssemblyResources AssemblyName
metadata 'Xamarin.Firebase.Messaging' FirePush.Android.
If I add the nuget package Xamarin.Firebase.Messaging the problem persists.
First things first, make sure you have all the packages that are required from firebase are included, and the packages are added to the respective native projects.
make sure to have the latest updates versions of the packages,
then, refer this blog and do the simple steps mentioned over there,
http://evanp.net/xamarin-did-not-find-reference-matching-restoreassemblyresources-assemblyname-metadata/
once you are done with that clean the solution and rebuild.
The reason this is happening is that AppCenter push notifications are wrapped over FCM which means it is directly dependent on it.
Required packages:
Since you are using the app centre in your application you will need Microsoft.AppCenter.Push.(Windows) or App Center Push. (MAC) package from NuGet,
Other than that you will have to add Xamarin.Firebase.Messaging Nuget to add the dependent firebase API's
Once you are done with this you will have to clean build and maybe even clear bin obj for it to work.

StorageCredentials.cs not found

I'm using WindowsAzure.Storage, in a .NET CORE 2.0 library (dll) but when I unit test I get StorageCredentials.cs not found.
public class AzureFileStorage : IDocumentStorage
{
CloudStorageAccount storageAccount;
CloudFileClient fileClient;
StorageCredentials credit;
public AzureFileStorage()
{
credit = new StorageCredentials(appSettings.Current.Settigns["azAccountName"],appSettings.Current.Settigns["keyValue"]);
storageAccount = new CloudStorageAccount(credit, true);
fileClient = storageAccount.CreateCloudFileClient();
}
}
I can navigate tot he file and the file/class is there, Am I missing something?
Also, the path starting C:\Program Files (x86)\Jenkins\ is nowhere to find on my computer.
According to your error message, I suppose the issue is related with Debug settings.
There are some ways you could have a try.
1.Open Tools>Debugging>General>tick Enable Just My Code. For more details, please refer to this article.
2.Right click "Solution >Properties and then go to "Debug Source Files". Check under "Do not look for these source files" window if you have your problematic file path written in it. For more details, please refer to this article.
Uncheck Enable source server support in Debugging/General.
4.The system has a StorageCredentials class. After I have installed WindowsAzure.Storage nuget package(like 8.7.0), I could use this class by adding using Microsoft.WindowsAzure.Storage.Auth reference;
5..Net core 2.0 compatibility.I also meet a similar error like you. Just the class is different. Above the package is an exclamation mark. It says this package version can not support .NET Standard 2.0. It supports in
version 5.2.4. You know the standard 2.0 is new, there are still some features can not support in it. You could also check your package dependencies of compatibility. If your error is this, you could to wait for core 2.0 to update to support for some packages. Or choose a compatible version of packages.

Clearscript V8 in ASP.NET 5 - v8-x64.dll could not be opened -- PE image doesn't contain managed metadata

I have issues with ClearScript. When I use them from regular project (class library or wpf), when dependency is added through nuget, also a post build script is added that copies ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll and v8-x64.dll to bin directory and everything works well. But when I try to use this library with new ASP.NET, things go wrong.
Nuget ClearScript package for dnx is downloaded to
C:\Users\lukasz\.dnx\packages\ClearScript.V8\5.4.3\lib\net40
I mean, ClearScript.dll is there but those 4 other files are not (they are ..\..\tools\native\{x86,amd64}\*, just like in case of desktop app), and when I run app it says
System.IO.FileNotFoundException: Cannot find file 'C:\Users\lukasz\.dnx\packages\ClearScript.V8\5.4.3\lib\net40\ClearScriptV8-32.dll'
So following my experiences from regular projects, I just copied those 4 files from
.dnx\packages\ClearScript.V8\5.4.3\tools\native\{x86,amd64}\*
to
.dnx\packages\ClearScript.V8\5.4.3\lib\net40
And then I get this error
Error: error CS0009: Metadata file 'C:\Users\lukasz\.dnx\packages\ClearScript.V8\5.4.3\lib\net40\v8-x64.dll' could not be opened -- PE image doesn't contain managed metadata.
error CS0009: Metadata file 'C:\Users\lukasz\.dnx\packages\ClearScript.V8\5.4.3\lib\net40\v8-ia32.dll' could not be opened -- PE image doesn't contain managed metadata.
I would asume that those dlls are somehow not valid for web version, maybe I need to get those dlls in some different way?
I could reproduce the issue creating new ASP.NET 5 project from WebApi template. I use single framework dnx46, no core as the projects I use are not compiled against it anyway. I use ClearScript.V8 5.4.3. DNX SDK version is 1.0.0-rc1-update1.
I am simply creating
var engine = new V8ScriptEngine();
in the controller method.

ActiveMQ No IConnectionFactory implementation found for connection

I have installed ActiveMQ 5.13.0 Release on the server and trying to access the broker with C# client. I created a console application and installed Apache.NMS.ActiveMQ version 1.7.1 nuget package. When I try to access the broker:
Line 1 Uri uri = new Uri("tcp://192.168.110.136:61616");
Line 2 NMSConnectionFactory NMSFactory = new NMSConnectionFactory(uri);
On the second line it throws No IConnectionFactory implementation found for connection URI: tcp://192.168.110.136:61616/ exception.
Project's .NET Framework version is 3.5 and I also tried with .NET 4.0 and 4.5 as well. But the result is same, throws the same exception.
ActiveMQ is running on the server and I am able to access to the server's 61616 port with telnet and the management UI. I checked other similar posts but did not help to fix the issue. Any help is welcome.
Thanks.
First, be sure that your applications references both the Apache.NMS.dll and the Apache.NMS.ActiveMQ.dll assemblies in order to have access to all the implementation bits.
Then try using a URI that references the provider implementation you are trying to use via the generic NMSConnectionFactory:
Uri uri = new Uri("activemq:tcp://192.168.110.136:61616");
Optionally you can use the ActiveMQ IConnectionFactory implementation directly:
IConnectionFactory factory = new Apache.NMS.ActiveMQ.ConnectionFactory(uri);
If anyone knows what is the difference between please explain.
In my project I had used a very old version (1.1) of Apache.NMS.ActiveMQ and it came with a file named nmsprovider-activemq.config.
When I upgraded I got into the same type of problems you observed.
What I found is that NMSConnectionFactory differs from earlier versions.
Newer versions has a lookup lists of pre-configured factory URLs (to locate the right assembly and factory implementation)
The name of the assembly can be overridden by the configuration file I mentioned. However, where old versions required the configuration file to provide the full name of the assembly (including the .dll file extension) the newer versions of NMSConnectionFactory calls Assembly.Load() which will fail in this case.
Simply loading the ActiveMQ assembly yourself and instantiate its factory is less complicated, but I guess switching between various factories becomes more of a chore then. The practical result (if you only care about one type of factory) is the same however. NMSFactory's main mission is to locate the factory class of the chosen provider.
The final pitfall when upgrading this assembly is that calling .Start() on the connection object is now required.
TL;DR: Check if you have the config file I mentioned. Either edit it (get rid of the .dll file extension) or remove it completely (it probably does not contain any info not already hard coded into the Apache.NMS assembly)

Categories

Resources