Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Are some .Net classes and methods not supported by Unity&UWP? (X509Certificate)

Discussion in 'Scripting' started by YiHan-GI, Apr 19, 2018.

  1. YiHan-GI

    YiHan-GI

    Joined:
    Mar 20, 2018
    Posts:
    9
    Hello,

    hereby is the problem description:

    [PROBLEM]
    Build to Universal Windows Platform fails with errors when I use System.Security.Cryptography.X509Certificates

    [ERROR]
    • Assets\Scripts\Client\MyOpcuaClient.cs(27,9): error CS0246: The type or namespace name 'X509Certificate2' could not be found (are you missing a using directive or an assembly reference?)
    [NOTES]
    I can build the project for Windows, It fails only when target is UWP.
    Unity uses .NET Core for UWP,which has X509Certificate.
    .Net as scripting backend.
    Switching scripting backend to IL2CPP will solve this problem, but it will also lead to other problems, so I'd rather stay with .Net.

    [REPRO]
    Add this code to your project, switch target platform to UWP, and build.
    Code (CSharp):
    1. using System.Security.Cryptography.X509Certificates;
    2.  
    3. public class Script
    4. {
    5. X509Certificate cert;
    6. }
    I have also checked this page: https://docs.unity3d.com/401/Documentation/ScriptReference/MonoCompatibility.html. If I understand correctly, these red Micros means that these methods are not supported by UWP?

    mono compatibility.jpg

    But the info there doesn't seems to be the latest, is there a new version?

    Thank you guys in advance!

    Edit:
    maybe this thread belongs to the windows platform subforum? If any moderator sees this, please move this thread to where you think suits it best:)
     
    Last edited: Apr 19, 2018
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,642
    It is true, .NET scripting backend on UWP has some classes and methods missing.
     
  3. YiHan-GI

    YiHan-GI

    Joined:
    Mar 20, 2018
    Posts:
    9
    Thank you.