C# Default parameters specifiers not permitted visual studio 2010 - visual-studio-2010

I am encountering a weird problem. Though I am using Visual Studio 2010 and targeting .Net 4.0 in my project, I keep receiver this error from the compiler "Default parameter specifiers are not permitted" for the following line of code:
public object GetContractCompSett(string compID, bool calcItemRoot = false, bool isSale = true)
{
....
}
While searching on the web (and on stackoverflow), the solutions point to the fact that name parameters and default value are a features of .Net 4 (the error is raised when targeting .Net 3.5 and below). But in my case, my compiler is set for .Net 4.0 still I receive this error. (I have spent the whole day trying to fix it....)
Thanks in advance for any hint.

Try switching your target framework to 3.5 then back to 4. That worked here and here.

Related

Why is the following line of code OK in VS2010 but not VS2012?

Unity version 2.1.505.0 in both WPF projects. One in 2010 & other in 2012.
In 2010 fine but 2012 I get Error "The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments"???
return this.Container.Resolve<Shell>();
Needed to add using for the Unity namespace as well as Prism.UnityExtensions. Answer was here on StackOverflow.

VS2010 - Unable to view variable value when debugging

I am using Visual Studio 2010 Version 10.0.40219.1 SP1
Recently I installed VS 11 Developer preview and since when my existing VS 2010 has been giving me some problems.
I have created a small console application in C# that makes use of .NET 4.0, nothing fancy - basically it creates a string variable and writes it to the console. This has nothing to do with code, but rather Visual Studio. Because of the following that happens afterwards:
I am unable to view any information about the variable when debugging within Visual Studio. When I start the debugger (which is in debug mode), the application starts and breaks at the given break point but, when it breaks, I am unable to view any information about any variable (view the value of the string value).
Even when I drag the variable into the Watch window it states the following:
Unable to evaluate the expression.
Why is this and how can I fix this?
I managed to solve the issue by re-installing VS 2010.
Many thanks for all the feedback!

Issues debugging Moles

I’m using visual studio 2008 and moles version 0.93. Everything works well except when I try to debug any test that uses a Moled type. The test skips all my breakpoints. And I get the following message in the output window:
Unable to attach. Check for one of the following.
The application you are trying to debug uses a version of the Microsoft .NET Framework that is not supported by the debugger.
The debugger has made an incorrect assumption about the Microsoft .NET Framework version your application is going to use.
The Microsoft .NET Framework version specified by you for debugging is incorrect
Please see the Visual Studio .NET debugger documentation for correctly specifying the Microsoft .NET Framework version your application is going to use for debugging.
If I try debbuger.Break () I get a message: "No symbols are loaded for any call stack frame. The source code cannot be displayed."
I’m in a crunch right now chasing an issue with one our main components and it has been a pain (like I need novocaine) trying to figure anything out without being able to step through the code.
I want to take advantage of mole's "smooth debugging experience". However, I can't seem to get the debugger to attach at all.
Thanks,
Bzz
See the solution to this issue here:
http://social.msdn.microsoft.com/Forums/en/pex/thread/91c08bf4-3260-458c-a221-91f030a75499
I had this problem when I moved a project from Visual Studio 2010 to Visual Studio 2008. Here's what I did to fix it.
Close Visual Studio. Navigate to the Debug/bin location. Delete the following files:
*.vshost.exe
*.vshost.exe.config
*.vshost.exe.manifest
Open the solution. Goto the project Settings. Under the Application Target Framework, select a framework lower than the one you are working with (you'll set it back later). Visual Studio will close and re-open your project automatically. Then set the Target Framework back to the original version you were working with. Rebuild all, and debugging will work properly.

VS2005 Options Generate Method Stub not working

Ok I installed the linq preview(May 2006) and it seems to have screwed me up. Now the one the of the most important features in VS2005 is not working anymore (Options Generate Method Stub (Shift+Alt+F10)). I used to get this message every time I would start a project
("This is an unsupported version of Microsoft Visual C# 3.0 / Microsoft Visual Basic 9.0. Therefor, many features may not work as expected.").
I uninstalled it and the feature is still not working but the error message is gone now.
If you don't know what I'm talking about if you type this simple code in you visual studio code editor: "string myString = GetString();" without declaring GetString() first, you will get a smart tag under GetString() and when you select it, you get a drop down that asks if you want to auto generate this method stub.
Is there a way to re-enable it?
Not sure why you installed this ancient version but did you also properly install dotNet 2?
You may have to re-install by hand.

Visual Studio 2008 not detecting Errors while coding

I just installed VS on another PC, but this time, while I am coding, it is not marking syntax errors while I am coding..... I need to press F6 to get the errors.
Normally when for example typing the line below, I get 's' underlined saying that there is a mismatch. Any ideas how I can enable this option?
string s = 4;
In order to enable background compilation for C#, which checks you code while typing for many types of errors that are usually only reported when you build the project, you will have to install Service Pack 1 for Visual Studio 2008. If you use the offline MSDN, you will also want to install the updated MSDN Library for Visual Studio 2008 SP1, since there were framework changes from .NET 3.5 RTM to .NET 3.5 SP1 (such as the addition of Entity Framework).
Have you recently deinstalled ReSharper?
(see responses in the same link for other possibilities).
C# has never been as consistent about finding errors while i type as VB.net has. I always assumed it was just due to the freeform nature of the language, which would also explain why C++ never found errors either til build time.

Resources