# Logic 2 automation via C# and NET Framework 4.8

**URL:** <https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171>\
**Category:** Support\
**Created:** [March 27, 2023, 4:30pm UTC](https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171 "2023-03-27T16:30:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschreier](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mschreier](https://discuss.saleae.com/u/mschreier)\
**Post date:** [March 27, 2023, 4:30pm UTC](https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171/1 "2023-03-27T16:30:52Z")

</div>

Hi, I am a new to Saleae, Logic 2 and GRPC. At work I received the task to integrate Logic 2 automation in our testing framework, but I am already getting really frustrated with it. NEED HELP !!!

So far, Logic 2 automation is distributed in a Python packages (not what I need).  
I got the proto file from the Python package and added it to my C# solution using the nuget packages Google.Protobuf, Grpc.Tools and Grpc.Core (deprecated, but working).

After digging through some code and documentation I got the following snipped to run:

```
        var channel = new Channel("localhost:10430", ChannelCredentials.Insecure);
        var client = new Manager.ManagerClient(channel);

        var reply = client.GetAppInfo(new Dust.Saleae.GetAppInfoRequest());
        MessageBox.Show(reply.AppInfo.ApplicationVersion);

```

The problem is that Grpc.Core is deprecated in favor of the Grpc.Net.Client nuget package. And here is where all the trouble starts.

1. Grpc.Net.Client is targeting NET.Core (we are using NET Framework 4.8)

2. You can use Grpc.Net.Client with NET Framework, however you must set the HttpHandler to the  
WinHttpHandler available via a nuget package System.Net.Http.WinHttpHandler. This is owed to fact  
of missing HTTP/2 support of the HttpHandler in the NET Framework.

3. The code snippet rewritten for Grpc.Net.Client now looks like that:

4. Ok, maybe my fault, because I specified “[https://localhost:10430](https://localhost:10430)”. Trying to use  
“[http://localhost:10430](http://localhost:10430)” throws another exception Grpc.Core.RpcException, HResult=0x80131500  
Message=Status(StatusCode=“Internal”, Detail="Error starting gRPC call. HttpRequestException: An  
error occurred while sending the request. WinHttpException: Error 12152 calling  
WINHTTP\_CALLBACK\_STATUS\_REQUEST\_ERROR, ‘The server returned an invalid or unrecognized  
response’.

5. Now it gets really bad. Digging through some more code including the low level python grpc stubs I  
see that the python stub defines the GetAppInfo method to use neither channel, nor call credentials  
with insecure set to false.

6. At this point I am ready to give up because I cannot figure out how to do this in the C# code,  
especially since the WinHttHandler requires TLS and any attempt to fiddle with the Credentials like  
setting them to ChannelCredentials.Insecure or SslCredentials.Insecure, etc… still produces the  
exception ‘The server returned an invalid or unrecognized response’

7. To me it looks like the main issues are  
a) The Logic 2 automation is using http instead of https (which seems to be the recommended  
way for GRPC)  
b) the promoted Grpc.Net.Client is targeting NET.Core with limited NET Framework support.

ANY HELP WOULD BE GREATLY APPRECIATED

Even better, maybe provide another IPC mechanism to control Logic 2 from a local PC.  
Even if I finally get it to run, I doubt that the solution will be very performant. With all the stuff regarding security etc… I would expect a call to take at least 30ms, probably with varying latency.

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [March 28, 2023, 1:07am UTC](https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171/2 "2023-03-28T01:07:33Z")

</div>

Sorry for the frustration with getting this working. I was in discussion with the software team last Friday about this (we saw your email come into our support inbox). It looks like you’ve provided more information on this forum post as well. Thanks for that.

We’ll let you know our recommendations / findings once we review this some more and have a grasp on what could be causing these issues for you.

---

<div class="post-metadata">

**Author:** ![markgarrison](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/markgarrison/32/23_2.png) [@markgarrison](https://discuss.saleae.com/u/markgarrison)\
**Post date:** [March 28, 2023, 8:01pm UTC](https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171/3 "2023-03-28T20:01:10Z")

</div>

@mschreier,

Sorry for the delay with this, and sorry for the trouble!

I’ve finished testing 3 different configurations:

- .NET 7, using Grpc.Net.Client
- .NET framework 4.8, using Grpc.Net.Client and both Grpc.Net.Client.Web and WinHttpHandler
- .NET framework 4.8, using Grpc.Core

I’ve found the same findings as you. There is no way to get .NET Framework 4.8 to work with Grpc.Net.Client, presumably because our application does not support TLS.

NET 7 worked just fine with Grpc.Net.Client, and framework 4.8 worked just fine with Grpc.Core.

Unfortunately, that’s all we can offer at the moment. I recommend you continue to use Grpc.Core even after the maintenance period ends in May.

The only alternative would be for us to add support for TLS, not something that we’re currently planning to add.

---

<div class="post-metadata">

**Author:** ![joerg.sch](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@joerg.sch](https://discuss.saleae.com/u/joerg.sch)\
**Post date:** [July 22, 2024, 8:44am UTC](https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171/4 "2024-07-22T08:44:17Z")

</div>

Hello, after a long break, I’m back to working with the API based on C# with Visual Studio.  
I’m able to successfully execute a “GetDevices(…”, but when I want to start a measurement I get an error in gRPC.  
Hence the question, can you send me a working Visual Studio example project from your tests?  
Regards, Jörg Schütte

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [July 26, 2024, 10:00pm UTC](https://discuss.saleae.com/t/logic-2-automation-via-c-and-net-framework-4-8/2171/5 "2024-07-26T22:00:31Z")

</div>

@joerg.sch Sorry for the late reply! We had some folks out of office during the past week.

What specific gRPC error are you getting? I’ll check with the software team when I meet with them next week if we have any examples we can immediately share with you.
