5 Replies - 1045 Views - Last Post: 29 January 2014 - 02:30 PM Rate Topic: -----

#1 programmingfan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 24-January 14

Why is My Visual Studio Acting UP?

Posted 29 January 2014 - 06:48 AM

Sometimes my code will not will not compile due to errors (VS should not return any errors for this code), but when I create a new project and paste the same code to the new project's .cs file it compiles and runs fine. Also, if the code returns errors (VS should not return errors for this code because the code follows programming rules), sometimes I have to close and restart Visual Studio in order to make it compile and run the same code without any errors.

whats going on here?

thanks.

This post has been edited by programmingfan: 29 January 2014 - 06:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Why is My Visual Studio Acting UP?

#2 Michael26   User is offline

  • Futurama: Insert funny joke here
  • member icon

Reputation: 414
  • View blog
  • Posts: 1,664
  • Joined: 08-April 09

Re: Why is My Visual Studio Acting UP?

Posted 29 January 2014 - 06:53 AM

Quote

Sometimes my code will not will not compile due to errors (there should not be any errors)

Well apparently compiler disagrees with you and his word is absolute, all joking aside it is always helpful when you post error message they can help you understand what is wrong. I think that is better solution than restarting VS. Are the errors related to the design file?
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Why is My Visual Studio Acting UP?

Posted 29 January 2014 - 09:34 AM

PEBKAC or ID-10t errors would be my guess.

But if the the same code works in a new project, then it might be a case of the solution files getting corrupted, other through your actions or not. Maybe a far-reaching global find and replace is affecting files that you don't open, but the solution needs. Maybe you have a drive going bad and files are getting corrupted. Maybe they files are open when Visual Studio crashes during debugging (it happens as a part of development) and is corrupting the files.

All valid reasons to make sure you're using some sort of versioning source control. Perforce offers a fully functional version for up to 20 users. That would let you use your home server for source control and a development for working copies. I really like it.
Was This Post Helpful? 1
  • +
  • -

#4 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7453
  • View blog
  • Posts: 25,095
  • Joined: 05-May 12

Re: Why is My Visual Studio Acting UP?

Posted 29 January 2014 - 10:18 AM

I used to be a big Perforce fan, but my preferences have now shifted to Mercurial. But any which way, using some form of source control is a must.

Now with regards to a project that seemed to be working seemingly failing down the road, by any chance are the following statements true:
- I am using WinForms
- I am creating my own User Controls
- I am putting my User Controls in my forms
- I put the User Controls is the same assembly/project as the forms that are using them
- I am addicted to using the Forms Designer

If all of those statements are true, VS sometimes gets into a corrupted state because the Forms Designer is trying to use the same assembly that you are currently working on and may have introduced errors into in the course of your work.

The way I usually workaround this is that I hand code my Windows Forms and User Controls instead of using the Forms Designer (eg. ala Java programmers). It works for me when I'm working alone, but I get a lot of angry co-workers when they want to use the Forms Designer to tweak my UI because they simply cannot.

The next workaround is to attempt to do a clean build, and kill the .SUO and .SDF files sitting around as well. This usually works.

The last workaround is to blow away the directory and pull the code from source control again. This is the "nuke from orbit" solution. It's the only way to be sure that you got a clean build.
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Why is My Visual Studio Acting UP?

Posted 29 January 2014 - 01:37 PM

I've done lots of WinForms, UserControls, Designer stuff... Even did a couple tutorials on it... and never had an issue. But my UserControls are always in their own namespace/assembly/project.

Personally I'd start by running a quality drive maintenance program to see if you have bad blocks/sectors on your HDD.
Next would be a quality RAM diagnostic. If you have a DIMM going out then the contents might be getting corrupt but only under certain conditions like when you max out the ram because the fault is in the last block of the chip.
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7453
  • View blog
  • Posts: 25,095
  • Joined: 05-May 12

Re: Why is My Visual Studio Acting UP?

Posted 29 January 2014 - 02:30 PM

I think that the key there is keeping the User Controls in a separate assembly. I'm surprised that M$ doesn't recommend this as a best practice. Perhaps it'll frighten Mort too much.

It definitely won't hurt though to do some extensive machine diagnostics to ensure that the corruption is not due to your machine malfunctioning.

Oh, yeah, another suggestion. The corruption seemed to be pretty common with VS2008 and VS2010. Try moving to VS2012 or VS2013.

This post has been edited by tlhIn`toq: 04 February 2014 - 05:59 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1