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

DriveInfo.GetDrives() crashes IL2CPP build

Discussion in 'Scripting' started by talofen, Apr 11, 2020.

  1. talofen

    talofen

    Joined:
    Jan 1, 2019
    Posts:
    40
    Code (CSharp):
    1. using System;
    2. using System.IO;
    3. using UnityEngine;
    4.  
    5. public class TestGetDrives : MonoBehaviour
    6. {
    7.  
    8.     // Update is called once per frame
    9.     void Update()
    10.     {
    11.         if (Input.GetKeyUp(KeyCode.P))
    12.         { GetDrives(); }
    13.     }
    14.     private void GetDrives()
    15.     {
    16.         try { Debug.Log("Trying GetDrives, found: " + DriveInfo.GetDrives().Length.ToString()); }
    17.         catch (Exception ex) { Debug.Log("DriveInfo.GetDrives exception: " + ex.Message); }
    18.     }
    19. }
    This script works flawlessly in the Editor and in Mono Builds, but if you build the app with IL2CPP, the app crashes whenever you hit P key.
    player.log reports the crash, but no exception is raised even though the GetDrives() call is within a try/catch block.

    Anyone has ideas?

    Tested on 2019.3.9f1 - windows target platform.
    Submitted as bug report, Case 1236557.
     
  2. talofen

    talofen

    Joined:
    Jan 1, 2019
    Posts:
    40
    Can anyone please confirm if it happens on my system only?
     
  3. yuichi9998

    yuichi9998

    Joined:
    Oct 25, 2017
    Posts:
    1
    I face the same issue now on Unity2019.4.6 and 2020.1.1....
    I haven't find any solution about this issue.
     
  4. benjamin_schmithuesen

    benjamin_schmithuesen

    Joined:
    Jul 23, 2020
    Posts:
    6
    CBHM likes this.