Integrate Google.Cloud.Vision sdk with AutoCAD .net plugin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi. I'm working with Google.Cloud.Vision.V1 package lately. I want to integrate some OCR feature with my .net plugin.
I tested the sdk in a simple c# console app project ( run in .net framework 4.8 ) at first and it works as expected ( can extract text from the image ). But I met some errors when the same code snippet run in my plugin project. Below is my code for extract text :
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Vision.V1;
var clientBuilder = new ImageAnnotatorClientBuilder()
{
GoogleCredential = GoogleCredential.FromFile("application_default_credentials.json")
};
ImageAnnotatorClient client = clientBuilder.Build();
Image img = Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\test.png");
IReadOnlyCollection<EntityAnnotation> textAnnotations = client.DetectText(img);
foreach (EntityAnnotation text in textAnnotations)
{
Console.WriteLine("\n" + text.Description);
}
the error occurs at line :
var clientBuilder = new ImageAnnotatorClientBuilder()
{
GoogleCredential = GoogleCredential.FromFile(credentialsPath)
};
the error message:
FileNotFoundException: Could not load file or assembly 'Google.Api.CommonProtos, Version=2.6.0.0, Culture=neutral, PublicKeyToken=...' or one of its dependencies.
I have bindingRedirect in my app.config as below but it seems like it's not working:
<dependentAssembly>
<assemblyIdentity name="Google.Api.CommonProtos" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.7.0.0" newVersion="2.7.0.0" />
</dependentAssembly>
All the dependencies is installed automatically when I install Google.Cloud.Vision.V1 via NeGet package manager. I didn't do any changes to the dependencies. I have no idea why this error occurs when running in AutoCAD plugin, while working well in other project. Has anyone encoutered similar problem before? I need some suggetions. Really appreciate for help!