Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Bug (Case 1155383) Exception thrown while invoking [OnOpenAssetAttribute]

Discussion in '2019.3 Beta' started by Peter77, May 17, 2019.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,605
    Right-clicking in the Project window provides the ability to "Open" always. Clicking the "Open" context-menu button, while no asset is selected, displays an ArgumentOutOfRangeException.

    Exception thrown while invoking [OnOpenAssetAttribute] method 'Unity.CodeEditor.CodeEditor:OnOpenAsset (int,int,int)'
    ArgumentOutOfRangeException: startIndex cannot be larger than length of string.



    Reproduce
    • Open attached project or create a new one
    • Right-click in the Project window while no asset is selected
    • Choose "Open" from the context-menu

    Actual
    Unity outputs an ArgumentOutOfRangeException exception.

    Expected
    The "Open" button should be disabled if there is no selection.
     
    Render_Man likes this.
  2. Yishi_

    Yishi_

    Joined:
    Jun 12, 2017
    Posts:
    2
    workaround:-
    open Preferences, to External Tools and reselect Visual Studio from the dropdown menu, it should resolve the problem.
     
    kkienchi, Nas_dev_ and Damlaalim like this.
  3. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,135
  4. squarelover

    squarelover

    Joined:
    Nov 14, 2012
    Posts:
    31
    still workaround need for a unity 2020.1.2f1
     
  5. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,475
    same here 2020.1.9f1 , I can't open visual studio c# script from unity.
     
  6. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,475
    it happen again 2020.2.1f1, 2.2f1, if open script within unity, then syntaxtree error occurs and VS-Unity not connected each other.
     
  7. SurreyMuso

    SurreyMuso

    Joined:
    Mar 16, 2020
    Posts:
    63
    And still in 2021.1.12f1
     
  8. weiqiang-huang

    weiqiang-huang

    Joined:
    Dec 17, 2021
    Posts:
    1
    And still in 2021.1.13f1
     
  9. unity_4BDF8A8FF3B23E739C9B

    unity_4BDF8A8FF3B23E739C9B

    Joined:
    Jun 16, 2022
    Posts:
    2
    have someone fixed this problem?
     
  10. itadakiass

    itadakiass

    Joined:
    Nov 11, 2017
    Posts:
    21
    Had the same error and this worked:
    Exit the unity, delete all auto-generated csproj and sln files from the root folder of the game, open the project again and generate them thru Preferences->External Tools->Regenerate project files.
     
    biibiia likes this.