Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by nckshr · Feb 20, 2019 at 03:22 PM · unityeditor.netsystem.ioserialport

System.IO.Ports missing for Unity with .NET 4.x

I very recently downloaded the stable release for Unity (2018.3.5f1). I have a project that talks to a microcontroller over the serial port, and in the past have used System.IO.Ports with no issue. However, just trying to import the namespace System.IO.Ports gives me this error in the editor and I am unable to compile:


error CS0234: The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)


As you can see below, my configuration settings are to use .NET 4.x and compatibility level is set to 2.0 (NOT subset, which isn't even available in the list):


alt text


If I set the "Scripting Runtime Version" to ".NET 3.5 Equivalent", the problem goes away. The only problem is that 3.5 is deprecated, and I would like to use something a little more future proof. Am I doing something wrong here? Do I need to check my .NET 4.x installation to see if it is missing some libraries? According to MSDN documentation, System.IO.Ports should be available in .NET 4.x. This problem persists across multiple machines & Unity installations of 2018.3.x. Any help greatly appreciated!!

unity-settings.png (8.3 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by xxmariofer · Feb 20, 2019 at 03:58 PM

Hello, you need to set api compatibility level to net 4.x(tested with 2018.3.0f2 version) alt text


sin-titulo.png (7.6 kB)
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nckshr · Feb 20, 2019 at 04:08 PM 1
Share

THAN$$anonymous$$ YOU! I could have sworn I tried that but indeed, switching the compatibility level to 4.x fixes it! After lots of searching and many posts from older versions that weren't relevant for me, I finally have the solution. Thanks again!

avatar image Clevereen · Oct 20, 2021 at 12:46 PM 0
Share

Thanks a lot, worked the same with my 2019.4.16 version

avatar image
0

Answer by soccer_guru · Mar 14, 2019 at 06:29 PM

I had the same problem, and I can confirm that you first need to switch to the deprecated .NET 3.5 Equivalent first, before switching to .NET 4.X and setting the API compatibility level. Switching the API Compatibility level first, weirdly, doesn't work.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xxmariofer · Mar 14, 2019 at 08:21 PM 0
Share

i didnt understand your post, you cant set up the compatibility level before changing the scripting runtime version since the first one is dependant of the second one. you cant have .net 4x without 4.x runtime version

avatar image soccer_guru · Mar 15, 2019 at 04:53 PM 0
Share

Hey @xxmariofer, I meant to say that switching to .net 4.x equivalent and setting the API compatibility level .net 4.x didn't work at once for me. It only worked after I switched to the .net 3.5 and then switched back to .net 4.x.

avatar image
0

Answer by CVTunity · Apr 30, 2019 at 03:16 PM

I also had the same problem. I used scripting runtime version .net 4.x Equivalent and Api Compatibility Level .Net 4.x. But I needed to build the solution in the IDE after switching from .Net Standard 2.0 to .Net 4.x

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

105 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

error with system.io.ports 0 Answers

How to fix TypeLoadException (EmguCV + Unity3d) 0 Answers

System.IO.Ports with .Net Standard 2.0? 1 Answer

Issues With Accessing Classes Nested In System.IO (Unity 2017.1.0f3) 0 Answers

HMAC Initialization throws and error. How to solve it 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges