EzDevInfo.com

visual-studio-2012 interview questions

Top visual-studio-2012 frequently asked interview questions

VS 2012: Scroll Solution Explorer to current file

VS2010 had the feature that viewing a file would automatically cause Solution Explorer to scroll to that file.

With VS2012, viewing different files from within the IDE no longer scrolls and select the file in Solution Explorer automatically.

Is it possible to get this feature back? Is there a setting somewhere? If so, how/where?


Source: (StackOverflow)

How do I undo "Scope to this" in Visual Studio 2012?

In the Solution Explorer, I clicked on "Scope to this" to display only a part of the solution. Now I can't find how to get back to normal view.

Closing/Reopening Solution Explorer won't work; I searched every menu item, and "New Solution Explorer View" didn't work either; I found nothing on Google.

I must be missing something obvious... There has to be an easy way to undo "Scope to this", right?


Source: (StackOverflow)

Advertisements

Format code shortcut for Visual Studio?

In eclipse there is a shortcut Ctrl+Shift+F that re-indents code and fixes comments and blank lines. Is there an equivalent for Visual Studio 2010?


Source: (StackOverflow)

'Specified condition "$(PackageAsSingleFile)" evaluates to "" instead of a boolean?

The visual studio 2012 on my PC get the following error message when preview in the "Public Web". I need to restart VS to get rid of the error message.

Invoke build failed due to exception 'Specified condition "$(PackageAsSingleFile)" evaluates to "" instead of a boolean. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets'

What caused the error?


Source: (StackOverflow)

Error: allowDefinition='MachineToApplication' beyond application level

I have downloaded the online project in ASP.Net. While running application I get an error

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

What changes should i make in web.config or elsewhere to make this work?


Source: (StackOverflow)

Disabling highlighting of current line in the Visual Studio 2012 editor

The Visual Studio 2012 editor highlights the current line by changing the background color of the current line. Is there a simple way to disable this highlighting? Otherwise, which parameter in Fonts and Colors dialog controls the background color of the currently selected line in the editor?


Source: (StackOverflow)

Where can I locate themes for VS2012

Okay, the lack of color on VS2012 is gross.

Is there someplace I can get a theme pack or something for it so that it actually looks reasonable? I really liked the look of VS2010. However, the new one reminds me way too much of 1984.

While we are at it, is there anyway to have it stop shouting at me? ALL CAPS menus are pretty hard to read. [ note: caps was resolved, thanks Konamiman]


Source: (StackOverflow)

How to add Web API to an existing ASP.NET MVC 4 Web Application project?

I wish to add an ASP.NET Web API to an ASP.NET MVC 4 Web Application project, developed in Visual Studio 2012. Which steps must I perform to add a functioning Web API to the project? I'm aware that I need a controller deriving from ApiController, but that's about all I know.

Let me know if I need to provide more details.


Source: (StackOverflow)

Visual Studio Debugging/Loading Very Slow

I'm at wits end. Visual Studio is typically painfully slow to debug or just plain load ("start without debugging") my MVC sites. Not always: at first, the projects will load nice and fast, but once they load slow, they'll always load slow after that. I could be waiting 1-2 minutes or more.

My setup:

I'm using Visual Studio 2012 express, currently, but I've had the same problem in 2010 as well. My solution is stored on a network drive; specifically, it's My Documents redirected to a network drive, if it matters. [It shouldn't. There are times where my site loads very fast under this setup.]

I load in IE 9 usually, but the same problem happens in FireFox.

This can happen in any MVC project I work on, and seems to revolve around having DisplayTemplates, which all my MVC projects do. And it's all C# & Razor, if that mattered.

Symptoms:

The system will load my symbols hundreds of times. Basically, the following, but there are at least 300 such rows, each with ever-so-slightly different DLLs for the same CSHTMLs:

'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_contact.cshtml.22013bb9.xighmhow.dll', Symbols loaded.
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_contact.cshtml.22013bb9.cv5hktkf.dll', Symbols loaded.
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.1o77hs8i.dll', Symbols loaded.
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.jja-77mw.dll', Symbols loaded.
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_location.cshtml.22013bb9.l_e9ev_s.dll', Symbols loaded.
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_location.cshtml.22013bb9.b4n59gom.dll', Symbols loaded.

In the above, I've got 3 DisplayTemplates: "Contact", "Location", and "StatusCode". It appears that IIS is loading symbols twice for each time the displaytemplate gets called. Thus, if I'm displaying a table of 100 entries that calls all 3 of these displaytemplates, it's 600 separate symbols loaded.

This isn't a fast operation either. Looking in the log files that IIS generates, it takes about 200ms for each symbol to load. Thus, super-long delays.

What I've Tried:

  • Debug or Release version, doesn't matter.
  • Putting my project on a full IIS implementation on a web server runs it super fast with no problems.
  • Cassini, iisexpress 7.5, iisexpress 8.0 all have the problem.
  • Delete All Breakpoints does nothing.
  • Clean Solution, or deleting the .suo also do nothing.
  • If I repair IISExpress, or delete the My Docs\IISExpress folder, or repair/reinstall Visual Studio -> the issue MAY go away, but only for a while, before it comes right back.

Any advice at all is appreciated.

---- Edit #1 -----

To answer more questions, yes my machine definitely has the horsepower. The infuriating thing is that the same project, with NOTHING altered, can load very very quickly sometimes, typically after I repair IISExpress & delete the My Docs\IISExpress folder. Eventually "something" happens and it's down to 2 minutes to load again. What I'm working on is not a complicated project. No external libraries or dependencies, and my VS.NET has no addons what-so-ever.

Of note, this machine has Symantec Endpoint Protection, which has a history of causing havoc. But disabling it outright (its good to be an admin) did not fix the problem.

I have a theory at this point. I'm thinking this is all because I'm working off a redirected folder off a network share. While the debugger was going through it's hundreds of "loaded symbols" lines, I paused to see what it was doing. It was in my code, loading the DisplayTemplate I had. Stepping into the template output this:

Step into: Stepping over non-user code 'System.Threading.WaitHandle.InternalWaitOne'
Step into: Stepping over non-user code 'System.Threading.WaitHandle.WaitOne'
Step into: Stepping over non-user code 'System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated'
Step into: Stepping over non-user code 'System.CodeDom.Compiler.Executor.ExecWaitWithCapture'
Step into: Stepping over non-user code 'Microsoft.CSharp.CSharpCodeGenerator.FromFileBatch'
Step into: Stepping over non-user code 'Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch'
Step into: Stepping over non-user code 'System.Web.Compilation.AssemblyBuilder.Compile'
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.bciuyg14.dll', Symbols loaded.
Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.CompileWebFile'
Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVPathBuildResultInternal'
Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert'
Step into: Stepping over non-user code 'System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory'
Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists'
Step into: Stepping over non-user code 'System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName'
Step into: Stepping over non-user code 'System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView'
Step into: Stepping over non-user code 'System.Web.Mvc.ViewEngineCollection.Find'
Step into: Stepping over non-user code 'System.Web.Mvc.ViewEngineCollection.FindPartialView'
Step into: Stepping over non-user code 'System.Web.Mvc.Html.TemplateHelpers.ActionCacheViewItem.Execute'
'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\b63f8236\6775085d\App_Web_statuscode.cshtml.22013bb9.kwj3uqan.dll', Symbols loaded.
Step into: Stepping over non-user code 'System.RuntimeType.CreateInstanceSlow'
Step into: Stepping over non-user code 'System.Web.Mvc.DependencyResolver.DefaultDependencyResolver.GetService'
Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerViewEngine.DefaultViewPageActivator.Create'
Step into: Stepping over non-user code 'System.Web.Mvc.BuildManagerCompiledView.Render'

It looks like VS is recompiling my displaytemplate every time it's called, which is again, hundreds of times. My theory is that VS compiles the file, saves it to the network share, the network share then somehow stamps a new time on it, and VS then thinks the file has changed and thus VS recompiles it yet again. Only a theory though; I really have no clue.

For one, apparently I have offline files on (this is a desktop computer in an office; I couldn't care less). I'm going to disable, reboot and retry tomorrow.

Plus, moving my project, as is, to the local C: fixes it. It loads very quickly. But this is not ideal in a work environment. I lose Previous Versions, my code isn't backed up at all unless I manually copy it, and it's no longer shared with anyone.

I can make do copying it back and forth from C to the network share, if it comes to it. It's much more annoying to wait 2 minutes for every page load.


Source: (StackOverflow)

Can I record/play Macros in Visual Studio 2012/2013/2015?

Apparently macros were dropped from VS 2012.

Is there a plugin/extension/tool that will let me record & play keyboard macros (much like the record/play temporary macro in VS 2010)?

E.g. I typically would use a macro when converting code from one language to another or to quickly generate properties from a text list, etc.


Source: (StackOverflow)

Why does this C++ snippet compile (non-void function does not return a value)

I found this in one of my libraries this morning:

static tvec4 Min(const tvec4& a, const tvec4& b, tvec4& out)
{
    tvec3::Min(a,b,out);
    out.w = min(a.w,b.w);
}

I'd expect a compiler error because this method doesn't return anything, and the return type is not void.

The only two things thing that comes to mind are

  • In the only place where this method is called, the return value isn't being used or stored. (This method was supposed to be void - the tvec4 return type is a copy-and-paste error)

  • a default constructed tvec4 is being created, which seems a bit unlike, oh, everything else in C++.

I haven't found the part of the C++ spec that addresses this. References (ha) are appreciated.

Update

In some circumstances, this generates an error in VS2012. I haven't narrowed down specifics, but it's interesting, nonetheless.


Source: (StackOverflow)

Converting VS2012 Solution to VS2010

I'm working in VB project with VS 2012 and after finish I try to add setup project.

I didn't find it (because the Setup Project was discontinued after VS2010) so I switched to VS2010 but the problem is the project wont open and I get this message:

The selected file is a solution file but was created by a newer version of this application and cannot be opened.

I tried this article : http://www.codeproject.com/Tips/80953/Converting-VS2010-Solution-to-VS2008 and tried to convert from 2012 to 2010 but same message appears.


Source: (StackOverflow)

How do I open an old MVC project in Visual Studio 2012 or Visual Studio 2013?

I have an old ASP.NET MVC 2 project which I do not want to upgrade to MVC 3 or MVC 4. I am working on a new machine running Windows 8, Visual Studio 2012 and Visual Studio 2013. When I try to open the MVC 2 project in VS 2012 or VS 2013 I receive the error:

This project is incompatible with the current edition of Visual Studio

The project is then unloaded and grayed out in Solution Explorer. I do not want to install another copy of Visual Studio. How can I open an old MVC project in a new version of Visual Studio?


Source: (StackOverflow)

Cannot install node modules that require compilation on Windows 7 x64/VS2012

I cannot install any of the modules that require compilation. All they fail with the following error:

MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". ...

My environment:

  • Windows 7 Enterprise x64, version 6.1.7601
  • node x86 0.8.16
  • npm 1.2.0
  • node-gyp 0.8.2
  • Visual Studio 2012 and numerous packages

Related environment variables:

Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShel l\v1.0;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\tools;c:\tools\node

No INCLUDE, LIB, LIBPATH, etc.

I did a short investigation of the issue and figure out that with the following setup the manual compilation (calling VCBuild.exe and msbuild.exe directly) succeed for the manually cloned git://github.com/einaros/ws.git:

SET Configuration=Release
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcpackages
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
SET PATH=%SystemRoot%\system32;%PATH%

SET INCLUDE=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\include
SET INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%

SET LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib
SET LIB=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\lib;%LIB%

SET MSBUILD="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"

VCBuild.exe C:\Tools\node\ws\build\bufferutil.vcproj "Release|Win32" /useenv
VCBuild.exe C:\Tools\node\ws\build\validation.vcproj "Release|Win32" /useenv
%MSBUILD% build/binding.sln /verbosity:diagnostic /nologo /p:Configuration=Release;Platform=Win32

I've tried to call node-gyp with the same variables and it failed:

C:\!> git clone https://github.com/einaros/ws.git
C:\!> cd ws
C:\!\ws>node-gyp configure
...
C:\!\ws>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.2
gyp info using node@0.8.16 | win32 | ia32
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=Win32' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\binding.sln]
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (c:\Tools\node\node_modules\node-gyp\lib\build.js:255:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\\Tools\\node\\\\node.exe" "c:\\Tools\\node\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\!\ws
gyp ERR! node -v v0.8.16
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok

Maybe you will have some ideas about it?

Thanks.


Source: (StackOverflow)

Where is the "Create Unit Tests" selection?

I have installed the new Visual Studio 2012 Ultimate.

I have created a Test Project with my solution and it contains some default unit tests. However right clicking on new Methods doesn't show the "Create Unit Tests" context menu any longer.

See Visual Studio 2010 Ultimate: enter image description here

And Visual Studio 2012 Ultimate: enter image description here

Any idea why that could be?

UPDATE:

Solution for Visual Studio 2012 and 2013:

Microsoft has acknowledged it here and offers an official work around patch to fix it. Download, install and Enjoy!


Source: (StackOverflow)