Reputation: 21
Getting below error while sending image to Google Api function
//Load the image file into memory
var image = Google.Cloud.Vision.V1.Image.FromStream(uplFile.PostedFile.InputStream);
// Instantiates a client
var client = Google.Cloud.Vision.V1.ImageAnnotatorClient.Create();
// Performs label detection on the image file
var response = client.DetectDocumentText(image);
Could not load file or assembly 'Google.Apis.Auth, Version=1.21.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
StackTrace: at Google.Api.Gax.Grpc.ChannelPool.d__5.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at Google.Api.Gax.Grpc.ChannelPool.CreateChannelCredentialsUncached() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Google.Api.Gax.TaskExtensions.WaitWithUnwrappedExceptions(Task task) at Google.Api.Gax.Grpc.ChannelPool.GetChannel(ServiceEndpoint endpoint) at Google.Cloud.Vision.V1.ImageAnnotatorClient.Create(ServiceEndpoint endpoint, ImageAnnotatorSettings settings) at.....
package.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.SqlServer.Types" version="11.0.1" targetFramework="net40" />
<package id="Google.Api.CommonProtos" version="1.1.0" targetFramework="net45" />
<package id="Google.Api.Gax" version="2.2.1" targetFramework="net45" />
<package id="Google.Api.Gax.Grpc" version="2.2.1" targetFramework="net45" />
<package id="Google.Apis" version="1.30.0" targetFramework="net45" />
<package id="Google.Apis.Auth" version="1.30.0" targetFramework="net45" />
<package id="Google.Apis.Core" version="1.30.0" targetFramework="net45" />
<package id="Google.Cloud.Vision.V1" version="1.1.0" targetFramework="net45" />
<package id="Google.Protobuf" version="3.3.0" targetFramework="net45" />
<package id="Grpc.Auth" version="1.7.0" targetFramework="net45" />
<package id="Grpc.Core" version="1.7.1" targetFramework="net45" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net45" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
<package id="System.Net.Http" version="4.3.1" targetFramework="net45" />
</packages>
web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.34.0.0" newVersion="1.34.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth.PlatformServices" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.34.0.0" newVersion="1.34.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.6.0.0" newVersion="3.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.CommonProtos" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.Gax" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Api.Gax.Grpc" publicKeyToken="3ec5ea7f18953e47" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Upvotes: 0
Views: 982
Reputation: 2390
First, I would check to see where you project file is looking for the DLL. You can find this by expanding dependencies in Visual Studio, right-clicking the Google.Apis.Auth dependency and selecting properties. My guess is that it is pointed at another copy of the DLL somewhere else on your machine that is not getting published. If that is the case, reinstalling via NuGet should do the trick (it will update the dependency reference in the project file). I would uninstall the package via NuGet, make sure it is removed from the dependencies list, then reinstall.
Second, try adding <bindingRedirect oldVersion="0.0.0.0-1.30.0" newVersion="1.30.0" />
to your web.config file inside the <dependentAssembly>
tag of the Google.Apis.Auth
dependency. This tells the application that you are satisfying the dependency with a newer version than the project is actually looking for. The section should look like the below. See the documentation for bindingRedirect
at here.
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth" publicKeyToken="xxx" cultuer="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.30.0" newVersion="1.30.0" />
</dependentAssembly>
Upvotes: 1