Two weeks ago, I decided to take a break from my Unity game project, but, when I came back, I was bombarded with errors on code that works just fine.
This screenshot best describes my problem:
When I hover over "using UnityEngine", it says it's an unnecessary using directive...
I know this problem
and it also happens to me when I take breaks from my code base.
To solve the problem you need to close VS Code and VS and then the Unity Editor as well. Be sure that even their processes are stopped (e.g. through the task manager). Then reopen your Unity Project and wait for all the loading processes to end(you can see that in Unity 2020.x.x in the lower right corner). Then doubleclick a script of yours to open up VS Code or VS. Important!! Dont press or type anything yet as the OmniSharp Server and all your extensions have to load in first. When you see the OmniSharp Server running in the lower left corner and it says "Ready", only then you can start coding.
Explanation
If VS Code isnt fully loaded and you start coding it doesnt detect all libraries and begins to act as mentioned. Be sure to only start coding when the VS Console says "Ready" in the lower left corner.
Related
I've been working on a C# MonoGame project for a few days now and so far it has been building and running fine. I left it alone for a while and, when I came back, the window would no longer display (running as a console application displays a blank console window, but not the application itself).
I don't think it's due to the code itself because the issue started happening without any changes to it.
When building, the program exits with code -1, as shown below in the output:
The program '[12460] Gearworks Physics Engine.exe' has exited with code -1 (0xffffffff).
Note that building the program gives no errors, warnings, or messages.
I realise there are a lot of posts related to "exited with code _" and I have seen some with code -1, but they weren't very helpful to my situation, so I've decided to post my own question instead. Let me know if there's any other information needed to help!
Solved - I simply needed to update Visual Studio to the latest version, which I was apparently not using. Once I did that, all programs worked again.
I'm having a really strange problem that I just can't figure out. Things I compile in Visual Studio 2015 (C# projects in WinForms and WPF) will not launch outside of Visual Studio. This includes a project that is completely new and untouched. As in, create a new WPF Application, build in debug and release. Go to containing folders click on EXEs and...nothing.
When I run them I get 3 processes appearing in Task Manager (named the same as my application) than cannot be killed (through task manager or command prompt) and nothing else occurs. Nothing in event viewer that seems to correspond to the app. I've attached an instance of VS 2015 to the process and I get the following message: WpfApplication.exe has triggered a break point. Pressing Break takes me to a screen that tells me no debug information is available and pressing continue has no visible effects (I can occasionally see slight movement in the cpu % but not a lot else). Any attempt to stop debugging will cause visual studio to hang and when I end its process VS closes but its memory is not freed up according to Task Manager. All of these same things occur when building in VS2013 and attempting to run outside of VS. Everything runs just fine when run in debug mode inside Visual Studio but outside of it...not a chance.
I literally have no idea where to proceed from here. I can find no error messages or clues to point me in a direction to look. Is there something I'm missing/doing wrong? What steps can I take from here to find the source of the problem?
I've considered it may be something wrong with my computer but I want to explore the possibilities before I do something drastic like a clean install. If the prevailing opinion lies that way then I'll seek help elsewhere!
tl;dr: launching the exe of a compiled application results in no running application and no obvious error messages, how can I proceed from here?
I'm going to post an answer to this because I found out what was wrong but it probably isn't useful to have it hanging around so I'll just delete the question at some point soon.
The main lesson to remember is that the main purpose of anti virus software is to frustrate you as much as possible and if something weird is happening try turning it off briefly and see what happens. You'll probably find that things are now working correctly.
EDIT: I should restate this in a more serious fashion.
Anti virus can sometimes affect things in unexpected ways and turning it off temporarily can save you a lot of time. Keep it up to date too, mine was a version or so old and was not functioning correctly. I updated it and the deep scan now functions as expected rather than silently failing.
Working with Monodevelop has been a nightmare overall. But among all the crashes, I have been able to recreate one of them reliably.
It seems like when I type "o" (the letter) when Monodevelop expects me to type an integer it will always crash.
Examples:
if (spriteRenderers.Length == o <----*CRASH*
for (int i=o <----*CRASH*
Now, of course, this typically only happens when I've made a mistake, but it does seem to be causing the crash.
And by "crash" I mean that Monodevelop stops working, and I get an error message from Windows asking if I would like to force quit the application. Upon re-opening Monodevelop it shows a blank white screen (every time).
The only fix I've found for the white screen is to delete the "Assembly-CSharp..." files in the project folder and then resync the Monodevelop project in Unity3D. I sometimes have to repeat this up to 10 times before Monodevelop will work again, and about half the time I lose a significant amount of work as a result.
Has anyone else experienced something similar? Any ideas on how to prevent this type of crash?
PS: It also tends to crash a lot when I'm typing "default" within a switch statement, but not every time like the "o" instance above.
If typing a specific letter crashes monodevelop there's certainly something going totally wrong here. First, confirm whether typing 'o' crashes monodevelop anywhere in any situation. Because I find it hard to believe that it crashes only when you type o where 0 is expected - because how would monodevelop know what is "expected" in a given situation? So unless that is confirmed, I assume this is not what is actually going on but rather something that you've came to conclude due to confirmation bias (ie it happend two or three times by chance in a situation where you intended to type 0 rather than o).
That said, check if any keyboard shortcut has been assigned to the letter o. You may want to reset keyboard shortcuts to their default. In general you may want to reset all preferences just to ensure monodevelop is using safe defaults for everything. Also check any plugin you may have installed, and disable them if only for testing.
You should also try shutting down Unity, and only run monodevelop. Then create a standalone project in monodevelop (ie C# windows app) to see if the problem also appears in "regular app development mode".
Lastly, upgrade Unity. If you are already on 4.6, get the latest "patch release" from the download page. This might also give you an updated monodevelop.
If all of that does not help, you may want to try Xamarin - the latest version of monodevelop. You can integrate that with unity by installing its Unity plugins, but currently it will not allow you to debug with Unity. In any case it installs itself side-by-side, so you should at least try that to see whether that has a similar problem.
If all of that fails, consider that the problem may be with your system. For instance a tool might have set a global keyboard shortcut on the letter o. A virus scanner or system driver may somehow interfere. Or the whole system is just whacky, perhaps a trojan, a hardware failure, and so on. That is all rather speculative, so at this point it's a matter of trial and error.
I have looked at all these but I have not as yet found an answer.
Now that time has moved on is there a solution to this?
Test win form target 3.5 or 4 net.
Win7 Ultimate 64 bit.
Project set to 32 bit as advised.
No fancy code or linked projects or dlls just a standard test project with no code.
I run the form than open the cs code for the form and press CR to add a comment.
I then get the error message...
Edit and Continue
Changes are not allowed while code is running or if the option 'Break all processes when one process breaks' is disabled. The option can be enabled in Tools, Options, Debugging.
My understanding was always that 'Edit and Continue' wouldn't allow you to edit code while your application is 'running'....
You need to pause your code; then you can 'continue'.
If your form is running and you want to add a comment to the .CS code - you need to either have your code hit a break-point first or manually pause your code (cntrl+alt+break - or available in Debug / Break All)
I seem to have the best luck with edit and continue when modifying code at or near the execution point. I'm sure someone can give a technical reason for this, but I don't know it off the top of my head.
(my apologies if you are doing this and I just misread your question)
Is it possible to rise a cmd.exe processes from the silent background mode to the visible foreground so I can LOOK at them?
Problem Background:
I'm using VS2008 working with a very large solution containing C#, C++, and Fortran. Occasionally (a few times a day) when building my project the build hangs and does not allow me to do anything in VS (resulting in the need to kill the process). I have checked the output box, and there appears to be nothing helpful there.
Possible Cause:
I am thinking that maybe one of the cmd.exe windows that are spawned in the background may be waiting for some form of input, but to investigate I need to see those windows.
Search for Other Causes/Solutions:
If not this, is there a way to try to check and see if there is something else going on? Is this a problem anyone else is having. (Note: killing VS and reloading often fixes the problem first try, and the build process takes less than 15 seconds.)
If stopping and restart fixes the problem, I guess it's not an input problem.
For example when my build project halts, it's always the VB6 project or SVN that are upset. (strangely the VS projects always work fine).
Once one of these halt, they halt until they are fixed. Thus for the VB projects run and work-out what the model dialogue is saying and fix it. or on SVN it usually need a clean-up run on the directory.
The intermittent nature suggests some sort of timing issue, like a file been lock open etc.
You could attach another copy of visual studio to the cmd.exe and see where it's at. Not sure if you can get symbols for it, so it might be fun to diagnose.