Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update transcoder example #1887

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Sep 21, 2022

  • Server SDK version
  • Transcoder package versions
  • Rename some transcoder UI elements

@JamesNK JamesNK force-pushed the jamesnk/update-transcoder-example branch from 4bd39c2 to 7903e5e Compare October 11, 2022 19:33
@JamesNK JamesNK merged commit cb02fb7 into grpc:master Oct 11, 2022
@JamesNK JamesNK deleted the jamesnk/update-transcoder-example branch October 11, 2022 19:51
@exquirentibus
Copy link

I enjoyed your video and am trying JSON Transcoding so that I can run gRPC Server using HTTP/1 on Windows Server 2016 (which apparently can't support HTTP/2 gRPC).

I had to add

using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;

to GreeterService.cs and then ran into an issue with

var builder = WebApplication.CreateBuilder(args);

in Program.cs that I couldn't easily fix as adding the VS2022 suggested

using Microsoft.AspNetCore.Builder;

Caused a problem with

builder.Services.AddGrpc().AddJsonTranscoding();

'IServiceCollection' does not contain a definition for 'AddGrpc'

But the concept of getting the changes necessary for JSON Transcoding are pretty simple and I was able to get it Almost completed in my gRPC Server application.

However .. I ran into one problem I can't figure out?

I'm using a GrpcShared shared project class library to store my Proto file between a Console client, Maui client and WPF client.

It was working perfectly before I added the changes for JSON Transcoding.

The GrpcShared class library project just had the example greet.proto file in the first level. No Protos folder.

I added a google folder and an api folder inside and placed annotations.proto and http.proto (the latest versions I believe) inside the google/api folders.

When I try to compile the GrpcShared class project, I get an error of:

Error CS0234 The type or namespace name 'Api' does not exist in the namespace 'Google' (are you missing an assembly reference?) GrpcShared G:\Projects\GrpcService\GrpcShared\obj\Debug\net7.0\Greet.cs 33 Active

which is of course the generated file.

The GrpcShared project definition is as follows:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
 
    <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
    <PackageReference Include="Google.Protobuf" Version="3.22.1" />
    <PackageReference Include="Grpc.Net.Client" Version="2.52.0" />
    <PackageReference Include="Grpc.Tools" Version="2.53.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
  </ItemGroup>
 
  <ItemGroup>
    <Compile Remove="HelloReply.cs" />
  </ItemGroup>

  <ItemGroup>
    <SupportedPlatform Include="browser" />
    <Protobuf Include="greet.proto" />
  </ItemGroup>
</Project>

I'm a bit stumped on how to proceed and had hoped to get some clues from your Example project.

One line in your project definition perplexes me?

<Protobuf Include="..\Proto\greet.proto" GrpcServices="Server" Link="Protos\greet.proto" />

as there Is no 'Proto' folder in the project? Only the 'Protos' folder and the above line refers to .. Both?

Any chance of a working gRPC Transcoding example that uses a Shared Project Class? Hopefully with the proto files at the first level (as the class is Only going to contain proto files)?

Or could you point me in the right direction for what must be an obvious mental failure on my part?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants