Возникла проблема при использовании Google Vision OCR API при размещении на IIS - PullRequest
0 голосов
/ 28 июня 2018

Ошибка ниже при отправке изображения в функцию Google Api

        //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);

Не удалось загрузить файл или сборку 'Google.Apis.Auth, версия = 1.21.0.0, Культура = нейтральная, PublicKeyToken = 4b01fa6e34db77ab 'или одна из ее зависимостей. Определение манифеста расположенной сборки не сопоставьте ссылку на сборку. (Исключение из HRESULT: 0x80131040)

StackTrace: в Google.Api.Gax.Grpc.ChannelPool.d__5.MoveNext () в System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start [TStateMachine] (TStateMachine & stateMachine) в Google.Arp.Chc.Cache.ChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChanChan.CanCacheChanChanChanChanChanChanChanCC. () в System.Threading.Tasks.Task`1.InnerInvoke () в System.Threading.Tasks.Task.Execute () --- Конец трассировки стека из предыдущего места, где было сгенерировано исключение --- в System.Runtime. ExceptionServices.ExceptionDispatchInfo.Throw () в Google.Api.Gax.TaskExtensions.WaitWithUnwrappedExceptions (Задача) в Google.Api.Gax.Grpc.ChannelPool.GetChannel (конечная точка ServiceEndpoint) в Google.Cloud.Vnision.not.Neate.InI.CateI Конечная точка ServiceEndpoint, настройки ImageAnnotatorSettings) в .....

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>

1 Ответ

0 голосов
/ 28 июня 2018

Сначала я бы проверил, где файл вашего проекта ищет DLL. Вы можете найти это, развернув зависимости в Visual Studio, щелкнув правой кнопкой мыши зависимость Google.Apis.Auth и выбрав свойства. Я предполагаю, что он указывает на другую копию DLL где-то еще на вашем компьютере, которая не публикуется. В этом случае переустановка через NuGet должна помочь (обновит ссылку на зависимость в файле проекта). Я хотел бы удалить пакет через NuGet, убедиться, что он удален из списка зависимостей, а затем переустановить.

Во-вторых, попробуйте добавить <bindingRedirect oldVersion="0.0.0.0-1.30.0" newVersion="1.30.0" /> в файл web.config внутри тега <dependentAssembly> зависимости Google.Apis.Auth. Это говорит приложению, что вы удовлетворяете зависимость с более новой версией, чем на самом деле ищет проект. Раздел должен выглядеть следующим образом. См. Документацию для bindingRedirect на здесь .

<dependentAssembly>
    <assemblyIdentity name="Google.Apis.Auth" publicKeyToken="xxx" cultuer="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.30.0" newVersion="1.30.0" />
</dependentAssembly>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...