Search Unity

trouble with com.unity.ide.visualstudio package

Discussion in 'Code Editors & IDEs' started by roointan, Jul 4, 2021.

  1. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    For debugging purposes, I have enabled a breakpoint to pause the program whenever an exception of type System.Exception is thrown.

    But I have a problem with com.unity.ide.visualstudio package code.
    It constantly keeps throwing an exception of type NullReferenceException, on line 63, inside OnIncomingConnection.

    I'm not sure what is the purpose of that method. But it comes in the way of debugging and breaks the debug flow all the times.
    I ended up adding this piece of code to the global cache, to prevent this from happening.
    I'm not sure how I can contribute to the actual project, but I hope some maintainer sees this and fixes this in the actual package.

    Code (CSharp):
    1.                 if(state.TcpListener == null)
    2.                     return;
    Thanks!
     
  2. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    Seems this doesn't totally fix the problem. I can still get this exception, to interrupt my debugging session:

    Message "Cannot access a disposed object.\nObject name: \'System.Net.Sockets.Socket\'." string

    "System.ObjectDisposedException: Cannot access a disposed object.\nObject name: \'System.Net.Sockets.Socket\'.\n at System.Net.Sockets.Socket.ThrowIfDisposedAndClosed () [0x0001b] in <aa976c2104104b7ca9e1785715722c9d>:0 \n at System.Net.Sockets.Socket.EndAccept (System.Byte[]& buffer, System.Int32& bytesTransferred, System.IAsyncResult asyncResult) [0x00000] in <aa976c2104104b7ca9e1785715722c9d>:0 \n at System.Net.Sockets.Socket.EndAccept (System.IAsyncResult asyncResult) [0x00000] in <aa976c2104104b7ca9e1785715722c9d>:0 \n at System.Net.Sockets.TcpListener.EndAcceptTcpClient (System.IAsyncResult asyncResult) [0x00034] in <aa976c2104104b7ca9e1785715722c9d>:0 \n at Microsoft.Unity.VisualStudio.Editor.Messaging.TcpListener.OnIncomingConnection (System.IAsyncResult result) [0x0001d] in /Users/p/Desktop/Source/Library/PackageCache/com.unity.ide.visualstudio@2.0.9/Editor/Messaging/TcpListener.cs:63 "
     
  3. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    Can I in any way instruct Visual Studio to ignore this file, from the general System.Exception exception breakpoint?
     
    viesc123 likes this.
  4. JPonzo

    JPonzo

    Joined:
    Sep 29, 2013
    Posts:
    5
    Hi,

    Same issue here except NullReferenceException is still raised inside OnIncomingConnection but line 60 instead of 63 (package version is not the same).

    I'm not sure it's relevant, but I use the Test Framework a lot and so far, the issue occurs only when I run the tests. Also, the tests are located in an embeded package not in the Asset folder.

    Versions of everything are :
    Unity : 2021.1.15f1
    VisualStudio Community 2019 : 16.6.2
    com.unity.ide.visualstudio : 2.0.11
    com.unity.test-framework : 1.1.27
     
  5. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    132
    Same issue. Does anyone know if this has been fixed? It's extremely annoying when trying to debug anything.
     
  6. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    I had to update the package, and here we go again. Need to patch the global cache of the newer version of the package again. I wish I knew who could help us with this issue from Unity, so I could mention the person.
     
  7. viesc123

    viesc123

    Joined:
    Dec 17, 2016
    Posts:
    12
    How do I modify the C# file from the package (or the global cache)? Unity (or Visual Studio?) will revert every change I make to the TcpListener.cs script.
     
    Last edited: Mar 11, 2022
  8. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    What platform are you on?
     
  9. viesc123

    viesc123

    Joined:
    Dec 17, 2016
    Posts:
    12
    I'm on Mac OSX (Monterey) / Unity 2021.2 / VS 2019 Community
     
  10. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    So you know, there's a dedicated sub-forum for this kind of stuff here.
     
    roointan likes this.
  11. viesc123

    viesc123

    Joined:
    Dec 17, 2016
    Posts:
    12
    Thanks! That looks promising. Would you mind moving the thread there?
     
  12. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    Global Cache locations: https://docs.unity3d.com/2019.3/Documentation/Manual/upm-cache.html

    For your platform you can find the file in this location:
    $HOME/Library/Unity/cache/packages/packages.unity.com/com.unity.ide.visualstudio@2.0.12/Editor/Messaging/TcpListener.cs

    (make sure you are using the folder with the right package version)
     
  13. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    Well you're not the OP and the thread is old so I won't move it now. For the future, you know about the other sub-forum though now. :)
     
  14. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    Do you know who can help fix this issue from Unity?
    this problem still exists even in version 2.0.16 and it's annoying having to include that code after every update.
     
  15. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    Unfortunately not.

    I'll move the thread to the correct forum I mentioned above though.
     
    roointan likes this.
  16. zwcloud

    zwcloud

    Joined:
    Mar 15, 2016
    Posts:
    377
    And then no one solves this issue:

    System.NullReferenceException: Object reference not set to an instance of an object
    at Microsoft.Unity.VisualStudio.Editor.Messaging.TcpListener.OnIncomingConnection (System.IAsyncResult result) [0x0000e] in D:\MyProject\Library\PackageCache\com.unity.ide.visualstudio@2.0.17\Editor\Messaging\TcpListener.cs:60
     
    Last edited: Dec 21, 2022
  17. redwyre

    redwyre

    Joined:
    Oct 14, 2018
    Posts:
    29
    I just started getting this while debugging tests, maybe something short lived.
    com.unity.ide.visualstudio@2.0.22