Google-cloud-dotnet: issue in class library with google voice to text api

Created on 12 Jun 2019  路  5Comments  路  Source: googleapis/google-cloud-dotnet

I have a class library project where I have all the Google voice2text transcribe api. When I am building the class library dll and using it to another application following error is throwing.

Could not load file or assembly 'Google.Apis.Auth, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The system cannot find the file specified.

speech needs more info p2 question

All 5 comments

It sounds like you haven't got the transitive dependencies working properly. In order to know how to fix this best, we need more context:

  • Are these .NET Core SDK style project, or "classic" ones?
  • How are you referencing the class library from the application?

With .NET Core SDK style projects, if you add a reference to the class library project I'd expect the .NET Core SDK to then restore all the transitive dependencies. If you're using a classic SDK style project, I believe you'll need to add dependencies in your application as well. Just adding a dependency on Google.Cloud.Speech.V1 should be enough, I believe.

It's a normal .Net Framework 4.6.1 project and I have used Nuget package manager to install all the Google Transcribe api. The project itself working fine when I am treating this as a Console application but when making it a class library and using project dll on another project reference then from that external project the error is throwing.

Yes, that's because classic projects didn't treat NuGet package references transitively. Options:

  • Add a reference to Google.Cloud.Speech.V1 in your console app as well
  • Convert to .NET Core SDK style projects (even if you still target net461) so that everything is restored transitively

Personally I'd recommend converting to .NET Core SDK style projects - the project files are much easier to work with, as well as fixing this issue.

Thank you very much. :)

I'll close this issue for now as those options should fix it; please add another comment if you run into trouble, and I can reopen.

Was this page helpful?
0 / 5 - 0 ratings