# Serial Connection DUT

**URL:** <https://forum.opentap.io/t/serial-connection-dut/915>\
**Category:** General\
**Created:** [October 31, 2022, 11:21am UTC](https://forum.opentap.io/t/serial-connection-dut/915 "2022-10-31T11:21:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscarkro](https://avatars.discourse-cdn.com/v4/letter/o/b487fb/32.png) [@oscarkro](https://forum.opentap.io/u/oscarkro)\
**Post date:** [October 31, 2022, 11:21am UTC](https://forum.opentap.io/t/serial-connection-dut/915/1 "2022-10-31T11:21:45Z")

</div>

Hi,

I’m looking into using OpenTap for our company. I’m busy developing some basic (fake) tests. The device will have firmware on it which can receive test commands via a serial connection. Now, i’m trying to open a serial connection, but I can’t get it to work.

The code looks like this:

![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/a20bc5c05b27b890b2fea57ef8a1f7d2c8f4ed0f.png)

The error message looks like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/52b101716339e631ef1a3e5113904ae9f5456021.png)

Does anyone have any idea why this doesn’t work? Or is there an example somewhere to create a serial connection? (Windows, C#)

Kind regards,

Oscar

---

<div class="post-metadata">

**Author:** ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)\
**Post date:** [October 31, 2022, 11:35am UTC](https://forum.opentap.io/t/serial-connection-dut/915/2 "2022-10-31T11:35:26Z")

</div>

Hi @oscarkro,

The problem is that you are using a System.IO.Ports DLL with an unspecified OS. This will cause it to select a generic / “cross platform” one, which is not implemented.

The easiest solution is to build for .NET framework instead of .netstandard, but you might also be able to specify RuntimeIdentifier as targeting e.g win10.

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [November 1, 2022, 4:18pm UTC](https://forum.opentap.io/t/serial-connection-dut/915/3 "2022-11-01T16:18:28Z")

</div>

Just corroborating what @rolf_madsen said, over here we build for .NET framework and successfully use the SerialPort class. Our code looks very similar to that shown by @oscarkro. Although I don’t see \_serialPort.Open() called, which I think will be necessary at some point.

I’m assuming the error gets thrown on this line:  
`_serialPort = new SerialPort();`

---

<div class="post-metadata">

**Author:** ![oscarkro](https://avatars.discourse-cdn.com/v4/letter/o/b487fb/32.png) [@oscarkro](https://forum.opentap.io/u/oscarkro)\
**Post date:** [November 3, 2022, 9:13am UTC](https://forum.opentap.io/t/serial-connection-dut/915/4 "2022-11-03T09:13:21Z")

</div>

Hi Everyone, sorry for the late responds. I’ll get back to it later. Daughter needs to go to the hospital so it’s a busy week. To be continued

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [November 3, 2022, 4:34pm UTC](https://forum.opentap.io/t/serial-connection-dut/915/5 "2022-11-03T16:34:38Z")

</div>

@oscarkro Take care and I hope your daughter gets well soon.

---

<div class="post-metadata">

**Author:** ![oscarkro](https://avatars.discourse-cdn.com/v4/letter/o/b487fb/32.png) [@oscarkro](https://forum.opentap.io/u/oscarkro)\
**Post date:** [November 7, 2022, 9:50am UTC](https://forum.opentap.io/t/serial-connection-dut/915/6 "2022-11-07T09:50:29Z")

</div>

Hi everyone. Thanks again for all the replies. It is fixed by setting the runtime identifier to the correct Windows.

Thank you all
