dotBunny / VSCode

Unity Visual Studio Code Integration
MIT License
673 stars 180 forks source link

Can't Start OmniSharp #2

Closed vexir closed 9 years ago

vexir commented 9 years ago

Looks like OmniSharp can't start, so many features aren't working? My log:

[INFO] Starting OmniSharp at '/Users/mathe015/Repositories/MatchThreeMoji/MatchThreeMoji-csharp.sln'...
[INFO] Started OmniSharp from '/Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/omnisharp' with process id 77938...
Can't find custom attr constructor image: /Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/approot/packages/Microsoft.AspNet.Cryptography.Internal/1.0.0-beta4/lib/dnx451/Microsoft.AspNet.Cryptography.Internal.dll mtoken: 0x0a000004
* Assertion at class.c:5695, condition `!mono_loader_get_last_error ()' not met
Stacktrace:

  at <unknown> <0xffffffff>
  at Microsoft.Framework.DependencyInjection.DataProtectionServices/<GetDefaultServices>d__0.MoveNext () <0x0021b>
  at Microsoft.Framework.DependencyInjection.ServiceCollectionExtensions.TryAdd (Microsoft.Framework.DependencyInjection.IServiceCollection,System.Collections.Generic.IEnumerable`1<Microsoft.Framework.DependencyInjection.ServiceDescriptor>) <0x00064>
  at Microsoft.Framework.DependencyInjection.DataProtectionServiceCollectionExtensions.AddDataProtection (Microsoft.Framework.DependencyInjection.IServiceCollection) <0x0002b>
  at Microsoft.Framework.DependencyInjection.MvcServiceCollectionExtensions.ConfigureDefaultServices (Microsoft.Framework.DependencyInjection.IServiceCollection) <0x0001b>
  at Microsoft.Framework.DependencyInjection.MvcServiceCollectionExtensions.AddMvc (Microsoft.Framework.DependencyInjection.IServiceCollection) <0x00013>
  at OmniSharp.Startup.ConfigureServices (Microsoft.Framework.DependencyInjection.IServiceCollection) <0x0003f>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
* Assertion at class.c:5695, condition `!mono_loader_get_last_error ()' not met
reapazor commented 9 years ago

This looks like something todo with VSCode installation more so then a plugin, and having looked at your attempts at UniVSCode as well I suspect there might be other issues at play.

Can't find custom attr constructor image: /Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/approot/packages/Microsoft.AspNet.Cryptography.Internal/1.0.0-beta4/lib/dnx451/Microsoft.AspNet.Cryptography.Internal.dll mtoken: 0x0a000004 Assertion at class.c:5695, condition `!mono_loader_get_last_error ()' not met

Seems to be the core of the issue, and unrelated to the plugin.

vexir commented 9 years ago

A VSCode rep I'm talking to suggested it might be an out of date version of Mono, but I just updated to the latest and it doesn't seem to help.

Any idea what might be the problem with my VSCode install?

reapazor commented 9 years ago

I just looked at my VSCode install ...

The error message ...

Can't find custom attr constructor image: /Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/approot/packages/Microsoft.AspNet.Cryptography.Internal/1.0.0-beta4/lib/dnx451/Microsoft.AspNet.Cryptography.Internal.dll mtoken: 0x0a000004

Mentions a path /Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/approot/packages/...

My install doesnt have that, I suspect yours is similar ...

/Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/packages/...

Would be the valid pathing (that nasty "approot" is killing you) to what its looking for, so I suspect something is fubar in a config somewhere?

vexir commented 9 years ago

Doesn't look like it. I was able to cd all the way down into where that Microsoft.AspNet.Cryptography.Internal.dll file is and it exists. Something it's doing perhaps is causing the error? I'm not sure how to debug any further...

reapazor commented 9 years ago

A quick googling gives me some ideas ...

http://stackoverflow.com/questions/8873091/mono-compiling-error-could-not-load-type-system-runtime-compilerservices-refe

Kind of suggests that the compiler you've got installed may be older then the latest, which would back what the Visual Studio Code rep was saying.

Did you install mono from source at any point in the past?

vexir commented 9 years ago

It's entirely possible, though I don't really remember it. I did do a

brew reinstall mono

which I'd imagine would have fixed it - my mono version now reads 4.2

vexir commented 9 years ago

Perhaps does Unity use a version of Mono that's installed somewhere else that isn't being updated by my terminal command?

reapazor commented 9 years ago

Unity itself has its own mono runtime, but we're not using that for any of this (nor is VS Code).

What I would personally do in this situation is uninstall from homebrew mono (hoping that it cleanly does it) and then download either mono directly from the source:

http://www.mono-project.com/download/

Or you can also grab Xamarin Studio, and have it install Mono for you (its made by the makers of Mono):

http://xamarin.com/platform

vexir commented 9 years ago

Hey! That did the trick. I guess home-brew was installing some crazy version of mono.

I'm getting code completion and go to declaration and all that fun stuff now.

Debugging doesn't seem to work however. Stuck a breakpoint in an update loop on one of my mono behaviors and it never got hit. The console log did say: [VSCode] Debug Port Found (56876)

Doesn't seem to have actually worked? Anything else I need to do?

reapazor commented 9 years ago

Did you go to the debug tab in VSCode and hit the play button there?

vexir commented 9 years ago

Yes, but I get a missing app.js error. Is that generated by the plugin?

launch: program '/Users/mathe015/Repositories/MatchThreeMoji/app.js' does not exist

It also doesn't look like the plugin is writing to Launch.json, which still looks like this:

            "name": "Attach",
            "type": "node",
            // TCP/IP address. Default is "localhost".
            "address": "localhost",
            // Port to attach to.
            "port": 5858,
            "sourceMaps": false

Is that something I have to modify manually?

reapazor commented 9 years ago

That is strange ... what version of Visual Studio Code are you using?

In Visual Studio Code 0.8.0, they moved the configuration directory, and the latest pull of my plugin has that, there is a previous release on the repo (https://github.com/dotBunny/VSCode/releases/tag/1.6.5) marked for Visual Studio Code < 0.7.2. It isn't as awesome as the latest version :) but it should work if that's the case.

You should never have to do that manually if the system is working properly ... I should add some more debug log messages for cases. If you are using the older version it probably made the .settings folder for you and put a launch.json file in there too ... but since the older version of Visual Studio Code doesn't know about that folder yet ... boo-urns.

vexir commented 9 years ago

Just updated to 0.8.0 and it works now. Might be a good thing to mention in the readme?

Thanks for all the help!

reapazor commented 9 years ago

No problem :) had me worried for a little bit.

I'll put a note in the README right now.

vexir commented 9 years ago

Looks like this process broke code completion in MonoDevelop. Is there a way to have both MonoDevelop and VSCode live alongside each other in peace and harmony?

reapazor commented 9 years ago

I believe so, I have to experiment with it a bit ...

Unity 5.2, I believe is where the feature shows up, that allows you to force the type of project / solution files that are saved out, and that would remove the need for me to scrub them.

This would then allow for the project file to be left in a state that MonoDevelop/Xamarin could use them

One option is to simply disable the integration from the menu, the generated project file should then work with MD.

vexir commented 9 years ago

Integration is not checked. Still getting no code completion/highlighting and strange "text editor error"s in MD.

System.NullReferenceException: Object reference not set to an instance of an object
  at MonoDevelop.CSharp.Completion.CSharpCompletionTextEditorExtension.GetParameterCompletionCommandOffset (System.Int32& cpos) [0x00000] in /home/builduser/buildslave/monodevelop/build/monodevelop/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs:524
reapazor commented 9 years ago

Hmm ... is that Unity's included MonoDevelop?

vexir commented 9 years ago

Yup!

reapazor commented 9 years ago

You just can't win :(

I double checked and MD, included with Unity does have its own version of the mono.framework, and to make matters worse, that chunk of code looks to be commented out in the latest versions of MD.

Just use VS Code? :)

vexir commented 9 years ago

Haha, I'm doing so now. I'm running into some auto complete problems however - some Unity system functions aren't completed, and go to file (command+P) seems to have to do a search every time I ask it to go somewhere. For instance, it wasn't able to autocomplete Debug.Log just now.

vexir commented 9 years ago

Erm, I also seem to have lost my go to declaration and all that, though I'm not getting any OmniSharp errors.

reapazor commented 9 years ago

Its a bug I just found I'm committing a fix momentarily.

vexir commented 9 years ago

Just grabbed latest (8:43 PST), doesn't seem to have fixed it. Where'd my code complete go :( VSCode doesn't even recognize the Time class and such things cry

reapazor commented 9 years ago

Not sure, I just checked and its still working for me ..did you play with the workspace exclusions by chance?

May need to write out new ones (which contain the solution and project files)

vexir commented 9 years ago

My workspace settings:

{
    "files.exclude": {
        "**/.DS_Store": true,
        "**/.git": true,
        "**/*.booproj": true,
        "**/*.csproj": true,
        "**/*.pidb": true,
        "**/*.sln": true,
        "**/*.suo": true,
        "**/*.user": true,
        "**/*.userprefs": true,
        "**/*.unityproj": true,
        "**/*.dll": true,
        "**/*.exe": true,
        "**/*.gif": true,
        "**/*.ico": true,
        "**/*.jpg": true,
        "**/*.jpeg": true,
        "**/*.mid": true,
        "**/*.midi": true,
        "**/*.pdf": true,
        "**/*.png": true,
        "**/*.psd": true,
        "**/*.tga": true,
        "**/*.tif": true,
        "**/*.tiff": true,
        "**/*.wav": true,
        "**/*.asset": true,
        "**/*.cubemap": true,
        "**/*.flare": true,
        "**/*.mat": true,
        "**/*.meta": true,
        "**/*.*.meta": true,
        "**/*.pidb.meta": true,
        "**/*.prefab": true,
        "**/*.unity": true,
        "**/*.3ds": true,
        "**/*.3DS": true,
        "**/*.fbx": true,
        "**/*.FBX": true,
        "**/*.lxo": true,
        "**/*.LXO": true,
        "**/*.ma": true,
        "**/*.MA": true,
        "**/*.obj": true,
        "**/*.OBJ": true,
        "build/": true,
        "Build/": true,
        "library/": true,
        "Library/": true,
        "obj/": true,
        "Obj/": true,
        "ProjectSettings/": true,
        "temp/": true,
        "Temp/": true
    }
}
reapazor commented 9 years ago

Yup, as I suspected.

https://github.com/dotBunny/VSCode/commit/a69432231c40fa2fdc7816c73919ae82e0e4f2df

Got rid of an issue where hidding solution and project files caused Visual Studio Code not to work right.

If you write out your workspace settings again it should fix that (with the latest)

vexir commented 9 years ago

That did it! Thanks!

VSCode did tell me that some things did not finish loading properly and when I clicked show Output, it tossed me to the OmniSharp log, the top part of which is this:

[INFO] Starting OmniSharp at '/Users/mathe015/Repositories/myProject/myProject-csharp.sln'...
[INFO] Started OmniSharp from '/Applications/Visual Studio Code.app/Contents/Resources/app/plugins/vs.language.csharp.o/bin/omnisharp' with process id 54691...
[INFORMATION:OmniSharp.Startup] Omnisharp server running using stdio at location '/Users/mathe015/Repositories/myProject' on host 54667.
[ERROR:OmniSharp.Dnx.DnxPaths] The specified runtime path 'default' does not exist. Searched locations /Users/mathe015/.dnx/runtimes/dnx-mono.default
/Users/mathe015/.dnx/runtimes/kre-mono.default
/Users/mathe015/.dnx/packages/KRE-Mono.default
/Users/mathe015/.k/runtimes/dnx-mono.default
/Users/mathe015/.k/runtimes/kre-mono.default
/Users/mathe015/.k/packages/KRE-Mono.default
/Users/mathe015/.kre/runtimes/dnx-mono.default
/Users/mathe015/.kre/runtimes/kre-mono.default
/Users/mathe015/.kre/packages/KRE-Mono.default.
Visit https://github.com/aspnet/Home for an installation guide.

Anything I should be concerned about?

reapazor commented 9 years ago

I've seen that Dnx path error pop up before, i dont believe its harmful ... but it is interesting that you are seeing it still.

It might be related to Visual Studio Codes bundled apps (https://github.com/OmniSharp/omnisharp-roslyn/issues/249) ... not exactly sure.

vexir commented 9 years ago

Gotcha. Good to know.

Debugging is working afaik, but it looks like hovering over a value doesn't do anything for member variables (class scope)? Locals work fine. The docs say you can inspect that way. Would that be a VSCode issue or could this integration be the cause?

reapazor commented 9 years ago

You know I was worried for a moment ...

You need to make sure to set the external editor in Unity to the Visual Studio Code app for it to work it seems, I'll see about adding something that does that for you :) I think thats a failsafe on their part so the process doesn't get unexpectedly high jacked.

reapazor commented 9 years ago
screenshot 2015-09-03 08 50 10
reapazor commented 9 years ago

Automatic support for this should be coming today, just have to finish up saving/restoring old when you disable the integration.

vexir commented 9 years ago

Just pulled latest - doesn't look like my External Script Editor changed. Changing it manually to VSCode also didn't fix the hover inspection problem (local variables still work).

I've also been getting a lot of Unity lock ups when debugging. I don't have specific repro steps yet, but will work on getting you some. It's usually when I try and hit resume in VSCode.

reapazor commented 9 years ago

I definately am going to need some reproduction steps on the External Editor Script test --- but it might be possible that you didn't turn off the integration and then turn it back on (its during the enable/disable process that it rights those changes).

But this does bring a good point up, if enabled I should enforce those settings always. noted

As for the lockups, ive seen them too ... i mean i know you cant go back to Unity till you resume/etc from VSCode. I suspect this might be a Visual Studio Code issue.

Your right hovering over I havent seen for debuggin, the local variables still work ... are you adding watches?

reapazor commented 9 years ago
screenshot 2015-09-03 18 08 59

It is odd ... but i think its Visual Studio Code's end

vexir commented 9 years ago

Yeah, there are other oddities. I just hit a breakpoint that I had turned off a while ago, and then when I tried to hit resume in VSCode, nothing happened. I hit stop in VSCode, and it released and went "blue", but Unity stayed stuck and now I have to restart it ;(

vexir commented 9 years ago

I think this debugging hang up piece is the last thing that I need to really jump on board with VSCode as my main code editor for Unity. Any ideas?

reapazor commented 9 years ago

I'm going to pass this little problem up the Visual Studio Code chain :)

It is almost like they are not sending the "stop debugging" command back to Unity.

vexir commented 9 years ago

Awesome. Keep me updated!

reapazor commented 9 years ago

https://vimeo.com/dotbunny/vscode

I was shooting this and even captured the hang in there :(

vexir commented 9 years ago

@reapazor had my coworker install the plugin from scratch - his external code editor changed automatically and everything, but it doesn't look like omnisharp finds his project automatically i.e. it says pick a project and his autocomplete doesn't work at all. I was so evangelical about the plugin too ;(

vexir commented 9 years ago

@reapazor I'm also not able to look into the contents of a List when I debug - it displays this error instead:

This request is not supported by the protocol version implemented by the debuggee.

I am able to use the debug console to see individual elements by i.e. myList[0] but that's obviously really tedious if I need to look at all the contents of the list.

reapazor commented 9 years ago

@vexir Is there any spaces in the project path ?

As for the list, that would be something for the Visual Studio Code team.

vexir commented 9 years ago

No spaces. The code completion is working for me, just not for my coworker. Not sure what's different about our installations.

Eshan

On Sep 8, 2015, at 12:27 PM, Matthew Davey notifications@github.com wrote:

@vexir Is there any spaces in the project path ?

As for the list, that would be something for the Visual Studio Code team.

— Reply to this email directly or view it on GitHub.

reapazor commented 9 years ago

Whats your path to your project, unity and vscode .... whats his?

reapazor commented 9 years ago

I've seen random occasions where VSCode didnt work, but then a force sync fixed it.

vexir commented 9 years ago

Mine:

/Applications/Visual Studio Code.app
/Applications/Unity/Unity.app
~/Repositories/myProject/

His:

/Applications/Visual Studio Code.app
/Applications/Unity/Unity.app
~/code/myProject/

Might be worth noting that when trying to manually select projects, we picked one of the .sln files and since then (even through relaunches of VSCode) his "flame" icon has been fading in and out and become unclickable.

reapazor commented 9 years ago

Any thing fancy (special characters?) in your user names?

vexir commented 9 years ago

Nope. Letters and numbers, no spaces.

On Tue, Sep 8, 2015 at 4:05 PM, Matthew Davey notifications@github.com wrote:

Any thing fancy (special characters?) in your user names?

— Reply to this email directly or view it on GitHub https://github.com/dotBunny/VSCode/issues/2#issuecomment-138727264.