4 MUST-KNOW tips for every Visual Studio user

  Visual Studio is Microsoft’s official IDE for the Windows Platform. It is also the most famous environment among programmers who develop applications for Windows. However, there are several issues faced by Visual Studio programmers. For instance, there are DLL errors, annoying compiler warnings, and overwhelming usage of disk space – to name a few. Therefore, we have listed several valuable tips for every Visual Studio User which would definitely help Visual Studio users to enhance their experience with Visual Studio. You can make Visual Studio run faster, reduce the disk space your projects occupy on your hard drive, make your programs portable, and so on. Just have a look at the following :

Tips for every Visual Studio user

#1 – Get rid of the Deprecated functions warning :

  As you might have noticed, several functions have been marked by Visual Studio as deprecated. This has been done because these functions have been found to be problematic in certain situations. There are ‘secure’ alternatives to such functions, which have certain differences in function name, argument list etc. If you use one of the ‘unsecure’ functions in your code, Visual Studio does not compile your program unless you replace those functions with their ‘secure’ versions.

For example, gets() and getch() have been replaced by gets_s() and _getch() respectively.

However, using these ‘secure’ functions has some drawbacks. These functions usually have a different set of arguments as compared to their predecessors.

For instance, gets() has been defined as char* gets(char* buffer). On the other hand, its secure version i.e. gets_s() has been defined as char *gets_s( char *buffer, size_t sizeInCharacters ). You can see how annoying this is. And if your project is large, with lots of such ‘deprecated’ functions, you’d probably find yourself cursing VS πŸ™‚ . To add insult to the injury, these ‘secure’ functions are not portable, so you can’t use that code outside VS.
Fortunately, there’s a simple workaround for this. Just deselect the “Security Development Lifecycle (SDL) checks” check box when creating a new project.

Disable Security Development Lifeycle (SDL) checks

Disable Security Development Lifeycle (SDL) checks

For existing projects, follow these steps :

a) Open your project in Visual Studio.

b) Right-click on the project name in Solution Explorer and Click Properties. The Property Pages window of your project will appear.

c) Click on Configuration Properties β†’ C/C++ β†’ Preprocessor Definitions.

Add _CRT_SECURE_NO_WARNINGS;

Add _CRT_SECURE_NO_WARNINGS;

d) In the Preprocessor Definitions field, addΒ  _CRT_SECURE_NO_WARNINGS; just before %(PreprocessorDefinitions).

Add _CRT_SECURE_NO_WARNINGS;

Add _CRT_SECURE_NO_WARNINGS;

e) Build your project, and say goodbye to these annoying warnings.

#2 – Use static linking instead of dynamic linking :

  This is one of the most important things a VS programmer must know. By default, VS builds your program to require dynamic linking. Therefore, some libraries (which are necessary for every program created using VS) have to be distributed along with the executables of your projects in the form of DLLs. Some of these DLLs (depending upon the version of Visual Studio you have) are : MSVCR120.DLL, MSVCR100D.DLL.
  In fact, you might have come across DLL errors, like the following one, while executing the program on a computer that does not have the appropriate version of MS Visual C++ Redistributable (Or, Visual Studio package itself) installed –

 

MSVCR120.DLL missing error

MSVCR120.DLL missing error

As discussed in our article – How to fix the “MSVCR120.dll missing” error and make your programs more portable, such errors are truly annoying and cause a lot of frustration for end-users and programmers alike. To eliminate this error, just perform the following steps:

a) Open your project in Visual Studio.

b) Right-click on the project name in Solution Explorer and Click Properties. The Property Pages window of your project will appear.

c) Click on Configuration Properties β†’ C/C++ β†’ Code Generation.

d) In the Runtime Library setting, select “Multi-threaded Debug (/MTd)” if your project configuration is “Debug” or “Multi-threaded (/MT)” if it is “Release”.

Fix the MSVCR***.DLL error

Fix the MSVCR***.DLL error

e) Click OK. Now, build the solution of your project by pressing F7. The new, standalone executable is ready. It does not need any DLL now. Therefore, now you can execute this program on any Windows Computer without worrying about “MSVCR***.dll missing” errors.

#3 – Save disk space by getting rid of unnecessary files

When you create a project in Visual Studio, several types of files are created automatically. Most of them are unnecessary for your project and the space occupied by them is overwhelming. In fact, these files tend to occupy more than 10 times the space needed for your source file(s) and executable(s).

Some examples of these are .sdf files and .ipch files.

Now, you can delete these files manually but doing so over and over again is such a tremendous waste of time and energy.

If you want to move these files automatically to some other location, and keep your project folders free of junk, follow these steps :

a) Open Visual Studio.

b) Go to Tools β†’ Options β†’ Text Editor β†’ C/C++ β†’ Advanced.

Set Fallback Location

Set Fallback Location


c) In the “Fallback Location”, set “Always Use Fallback Location” to True and “Do Not Warn If Fallback Location Used” to True. In “Fallback Location” you can either put a path like C:Temp or if you leave it blank then VS will use the temporary directory in your AppData folder. You can see this in the above image.


If you don’t want to create these files at all (and save disk space), follow these steps :

a) Go to Tools β†’ Options β†’ Text Editor β†’ C/C++ β†’ Advanced.

b) Set ‘Disable Database’ to True, as shown in the image below.

Disable Database

Disable Database

c) Build your project. Please note that .sdf files are necessary for using IntelliSense. If you disable the database, no .sdf file will be created and thus you won’t be able to use IntelliSense.

#4 – Make Visual Studio faster by disabling unnecessary features

  Obviously, you must have observed that Visual Studio gets very slow at times. No matter how fast your hardware is, VS doesn’t respond as quickly as you want it to.

  This happens because of several built-in features of Visual Studio which you most probably don’t need. Also, there are some settings which could be modified to get better performance.

a) Turn off animations

Go to Tools β†’ Options β†’ Environment and uncheck “Enable rich client visual experience” and check “Use hardware graphics acceleration if available”. This will make VS faster since it relies on your GPU instead of your CPU for creating graphics. Also since there will be less animations, VS will become more responsive and will not lag while you’re working.

b) Disable Start Page

Go to Tools β†’ Options β†’ Environment β†’ Startup and select Load last loaded solution from the At Startup dropdown. This loads the project you were working on in your previous session when Visual Studio loads, thus saving time.Β 

  Also, uncheck the “Download content every” check box. This would prevent Visual Studio from connecting to the internet frequently.

c) Disable automatic check for updates

Β 
Go to Tools β†’ Options β†’ Environment β†’ Extensions and Updates, and uncheck “Automatic check for updates”. This would prevent VS from connecting to the internet again and again.

d) Turn off Track Active Item

Go to Tools β†’ Options β†’ Projects and Solutions and uncheck “Track Active Item in Solution Explorer”. This will ensure that if you are moving across files in different projects, the left pane will still be steady instead of jumping around.

e) Turn off Track Changes

Go to Tools β†’ Options β†’ Text Editor and uncheck “Track changes”. Doing so will lead to overhead reduction and will speed up the IDE, making it more responsive.

(Visited 582 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *