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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

FileSystemWatcher not implemented on .NET 4.x with .NET Standard 2.0 only?

Discussion in 'Experimental Scripting Previews' started by bdovaz, Aug 2, 2018.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,015
    @strich @JoshPeterson

    Case number: 1066732


    WORKS!!


    Version:
    2018.2.1f1
    Scripting Runtime Version: .NET 3.5 Equivalent
    Scripting Backend: Mono or IL2CPP
    Api Compatibility Level: .NET 4.x
    Player: Windows

    WORKS!!

    Version:
    2018.2.1f1
    Scripting Runtime Version: .NET 4.x Equivalent
    Scripting Backend: Mono or IL2CPP
    Api Compatibility Level: .NET 4.x
    Player: Windows

    DOESN'T WORK!!

    Version: 2018.2.1f1
    Scripting Runtime Version: .NET 4.x Equivalent
    Scripting Backend: Mono or IL2CPP
    Api Compatibility Level: .NET Standard 2.0
    Player: Windows



    With .NET Standard 2.0 I get the following error:

    According to this page "FileSystemWatcher" is part of .NET Standard 2.0:

    https://apisof.net/catalog/System.IO.FileSystemWatcher

    Inspecting Unity's fork of Mono I see this (fake) class:

    https://github.com/Unity-Technologi.../System/System.IO/FileSystemWatcher_mobile.cs

    In the original Mono repo there is no "FileSystemWatcher_mobile.cs" and it uses the same working implementation for all platforms:

    https://github.com/mono/mono/tree/master/mcs/class/System/System.IO

    I'm using a Microsoft open source library (.NET Standard 2.0) that has a dependency of another library that make use of this class and I can't use it...

    https://github.com/aspnet/FileSystem

    Specific usage of "FileSystemWatcher" class:

    https://github.com/aspnet/FileSystem/blob/2.1.1/src/FS.Physical/PhysicalFileProvider.cs#L78

    In the repro project I made it simpler and I only instantiate the "FileSystemWatcher" without any dependency and you can see that it throws that exception.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    Thanks for the details. Can you submit a bug report for this issue?
     
  3. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,015
    You already had it on the top of my post really big. ;)
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    How did I miss that? Thanks!
     
  5. anandpadiya

    anandpadiya

    Joined:
    Nov 14, 2018
    Posts:
    1
    I am still getting this issue in 2018.3.0f2.
     
    Last edited: Dec 14, 2018
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
  7. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hey, we've been getting this problem on .NET 4.x, for Android and iOS, both IL2CPP and on Unity 2019.2.9f1. We didn't have this problem previously on 2017.4.11f1 (we were using backend .NET 4.x already). We skipped Unity 2018.

    I find it strange that neither this:
    https://issuetracker.unity3d.com/is...on-net-4-dot-x-with-net-standard-2-dot-0-only
    nor this:
    https://issuetracker.unity3d.com/is...temwatcher-not-implemented-on-net-4-dot-x-api
    are marked as regressions.

    But I think we might have separate issues.
    1. .NET Standard 2.0 doesn't have FileSystemWatcher implemented on Windows. I've never tested this. It is not our issue.
    2. iOS and Android IL2CPP builds also don't have it implemented, even on .NET 4.x. This DIDN'T happen in 2017.4.11f1, at least on iOS (at that time we used Mono for Android).
    Can you confirm if you know of this problem, @JoshPeterson? Will fixing 1. also fix 2.?

    Unfortunately we didn't notice this problem on iOS and Android for a while, and have been developing on Unity 2019.2.9f1, so this regression is delaying our release because we need the FileSystemWatcher.

    Will this fix exist in 2019.2.x? Upgrading to 2019.3 and risking breaking things is something to avoid for us right now.

    Thanks!
    Daniel
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    It looks like we are not planning to back port this fix to 2019.2. We can assess the risk though, and see if it will be possible.
     
  9. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Thank you @JoshPeterson. If the team could back port it we'd really appreciate it.

    But can you confirm that the fix for issue 1 and 2 is the same?

    In the meantime I've confirmed that Mono Android builds don't have this problem. Only IL2CPP. I reported it as a bug, mentioning the other existing issues.

    It seems that our issue is more similar to the second issue I linked (even though it's for Windows it's not about .NET 2.0 at all) but that one is marked as a duplicate of the first, and it doesn't look like it is a duplicate.
     
  10. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    The release notes for 2019.2.10f1 also don't mention this in the known issues, which is a bit concerning considering the age of this bug. :) (I guess you can't possibly list ALL known issues, but this one break some builds silently, since the problem only happens at runtime).
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    Yes, the fix for 1 and 2 is the same (at least with IL2CPP). The Api Compatibility Level setting only controls the profile that code compiles against. The key problem here is the implementation of the class libraries. The Mono scripting backend has one implementation, the IL2CPP scripting backend as another.
     
  12. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    @JoshPeterson OK, thank you for explaining. I noticed that my bug report actually didn't go through since the reporter is erroring when creating the archive, but in that case my report doesn't seem necessary anymore.
     
  13. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    I would be grateful if you could update me later on the state of the back port for 2019.2. The final 2019.3 version is still a while away and even then updating may result in hidden problems in our project. :(
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    Ok, it looks like we will be able to back port the fix for this issue to 2019.2.

    EDIT: I've changed the version number to 2019.2, as intended.
     
    Last edited: Oct 29, 2019
  15. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    You mean 2019.2, right? If so that's really great for us.
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    Yes, that was quite an important typo.
     
  17. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    ;) Thanks a lot, we'll keep an eye on future release notes for 2019.2.
     
  18. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,015
    CanisLupus likes this.
  19. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    Still problem on 2018.4.15 Any fix for that?
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    We're not planning to back port the fix to 2018.4.
     
  21. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    SO what exactly We should do? I thought 2018.4 Is Long term Support version? but there wont be a fix? I dont understand
     
    Qbit86 likes this.
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    I believe that you can use the .NET 4.x Api Compatibility Level to get support for the File Watcher in Unity 2018.4.
     
  23. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    OK What we exactly see is :
    upload_2020-1-23_20-13-2.png

    I think thats not connected WIth net 4.x problem, Cause even after changing that the problem is still here, Even after removing all.dlls from projects and turning on new empty scene and click play, there is that error. IT is very simillar Maybe you already have experience with that?
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    This does look like a different issue. It seems that Environment.FailFast is being called, and that is what is not implemented. I wonder why, is that being called though? Do you expect that to be called? Maybe there is another higher-level error lurking here.
     
  25. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    This happend after upgrading from unity 2018.2. to Unit y2018.4 and the problem occurs every time I go to playmode, and cant build a game becasue of that (for playmode this is not to harmfull cause it happends only on start)

    I read that it cant be traced cause could be from so .dlls, I removed all of it but it still here. Dont have idea how to fix that. Maybe it is because od some of Unity packages? that was automatically updated after umnity update? Cant see higher level error cause Console show nothing about it. If you have any ideas how to test it more, or isolate problem or files that could made that I will be grateful
     
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    I would recommend recommend attaching a manage debugger to Unity, then see if you can make this happen. Maybe that will help.

    The call stack seems to indicate this is happening on a background thread created from C# code via System.Threading.Thread, but that's all I can tell.
     
  27. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    Also we changed to NET 4.0 from 3.5 but cant remember if Bug was here right after upgrading unity to 2018.4 or after changing to NET 4.0
     
  28. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    What about debugger, We tried it and nothing found. Will try again. But dont exactly know what we should track if we dont have certain script
     
  29. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    What about debugger, We tried it and nothing found. Visual Studio debugger dont event show that error that is showed in unity console that screen I send above.
     
  30. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    @JoshPeterson Its seems like we found it it is in "mscorlib.dll" in mono upload_2020-1-24_0-24-10.png

    file is in "Unity\Editor\Data\Mono\lib"

    But dont exactly know how to fix now. Looks like unity bug?

    We tested it also with visual to check is there any reference in any of our script project to that function. And nothing found. So it has to be a Unity Bug. Tried With NEt 4.0 api compability Standard 2.0 and Net 4.x no matter what we choose problem is always here.


    EDIT:
    We changed our project back to NET 3.5 and problem Dissapeard but The other problem is that we use Polybrush and Polybuilder package that work only on on NET 4.0 So that is unity bug and need to be fixed cause using NET framework 4.0 with unity 2018.4.15 will show that exception.
     
    Last edited: Jan 24, 2020
    MechEthan likes this.
  31. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    @JoshPeterson I reported That bug issue: 1214089 For now without fixing it we cant even build a game, or we have to resign from NET 4.0 and from polybrush that dont support net 3.5 and we already have prepared a lot of meshes with that so We cant resign from that. Let me know if you need any other info
     
    LostPanda likes this.
  32. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    168
    using 2018.4.23f1 build and run il2cpp mode alway show:Unity: NotImplementedException: The method or operation is not implemented.[System.IO.FileSystemWatcher]

    using net 4.0.Can't figure it out, a long term support version that doesn't fix the problem!

    @Jakub_Machowski @JoshPeterson
     
  33. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    We're worried that this change it too risky to back port to an LTS release, so we've not planning to ship it in 2018.4.
     
  34. andrew-lukasik

    andrew-lukasik

    Joined:
    Jan 31, 2013
    Posts:
    239
    Hi @JoshPeterson ,

    I'm seeing this issue reappear in
    2021.2.0a21


    To reproduce it:

    1. Download project files: https://github.com/andrew-raphael-l...tree/facb4abd713ef6a4b5654527a763539e7e0cf41d (
    2021.2
    branch, commit
    facb4abd713ef6a4b5654527a763539e7e0cf41d
    )
    2. Open it with Unity
    2021.2.0a21

    3. Build it using Windows build config asset (ctrl+shift+b gave the same results)
    4. Drag and drop
    *.log
    file over built executable and read it's player log (
    C:\Users\USER_NAME\AppData\LocalLow\Andrew Raphael Lukasik\Unity Log File Reader\Player.log
    )


    EDIT: Case 1344045
     
    Last edited: Jun 17, 2021
    l_racher likes this.
  35. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,760
    Can you drop us a new bug report for this issue? We will correct it. Thanks!