Posted by Vakul Kumar More on September 11, 2012
.NET / Visual Studio
Posted in Useful Links | Tagged: .NET, ASP.NET, C# 3.0, Microsoft, MSDN, Vakul, Vakul Kumar, Vakul Kumar More, Visual Studio 2008, Visual Studio 2010 | Leave a Comment »
Posted by Vakul Kumar More on January 12, 2012
Developers spend most part of the day with Visual Studio and using shortcuts and hidden features would definitely improve the productivity.
I’m presenting few tips and Tricks along with hidden features and customizations for the developers. Please add any new features in the comments section.
Developers sometimes get distracted with the alerts and there is a solution for that. Alt-Shift-Enter toggles from regular view to full screen mode, so you can see a lot more code. Windows Task bar is also hidden and definitely productive.
We don’t have to select a complete line to copy or delete it, use CTRL-C/CTRL-X anywhere in the line.
- Saving And Restoring Visual Studio Settings
Tools –> Import and Export Settings can be used to export the settings to an other machine.
Visual Studio default settings can be restored by selecting “Reset all Settings”
- Select a rectangular area of text.
Hold Alt down and drag mouse over text area you like to select.
If you’re debugging through a loop, waiting for something specific to happen—like a variable to have a specific value—use the Conditional Breakpoint capability. When you set a breakpoint, right-click on its red blob and choose “Condition…” in the popup menu.
- Use line numbering on your source code editor.
Using line numbers largely improves productivity, especially when four eyes are looking at a code and discussing it. Turn on line numbering by going to the menu Tools | Options. Look for Text Editor | All Languages | General and check the
“Line numbers” checkbox.
- View different parts of the same document.
Sometimes, it’s good to view different parts of the same document for reference purposes. At the very top of the scrollbar, there’s a little rectangle. Click and drag that down for two windows into the same code file. When done, simply drag back the splitter to collapse the window.
- See List of 10 Recent Projects in window menu, Not Just 4
On the Tools->Options->Environment, you can have Visual Studio show the 10(Maximum is 24) most recent projects you’ve opened, rather than just the most recent 4. (This also works in Microsoft Office and many other applications.)
- Find in Visual Studio IDE
Ctrl+F is known to all developers to find a word or string in current document, all open documents or entire project or entire solution. One other hidden option is Ctrl+Shift+F, this is helpful by listing results in a find window unlike navigating one by one in every file where the searched word/string exists.
To incrementally search for text as being typed, first press
Ctrl+i. Then type the word to be searched. Hit backspace to clear a character and enter to finish. Pressing F3 after this will work as usual, i.e. search for the next occurrence of previous search.
Ctrl+i works like F3.
- Important Shortcuts in Visual Studio IDE
Ctrl+Alt+L – Opens Solution Explorer
Ctrl+Alt+X - Shows Toolbox
F4 – Opens properties window
Ctrl+\+E – displays error list
Ctrl+\+T – displays tasklist
Ctrl + M + M – Expanding and collapsing code blocks
- Surround with code Snippet (C#)
Snippet can be placed around a code block using shortcut CTRL+K+S.
- Image library by Microsoft to use in Visual Studio applications
During the Visual Studio setup, the VS2008ImageLibrary.zip file is installed at \Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\
I will keep updating this post, please let me know if you know of any tip.
HAPPY PRODUCTIVE CODING
Posted in Tips & Tricks | Tagged: C#, Tips & Tricks, Vakul, Vakul Kumar, Vakul Kumar More, VB.NET, VB9, Visual Studio 2008 | 12 Comments »
Posted by Vakul Kumar More on November 2, 2011
I have been passive for quite some time and would like to be back into regular blogging.
Today, I present an eBook which is available for free.
The developers guide to AppFabric – October Edition.
Alan Smith is the author of the book and explains “The Developer’s Guide to AppFabric” is a free e-book for developers who are exploring and leveraging the capabilities of the Azure AppFabric platform. Click here to download. You can visit here for the latest edition of the book.
Happy coding 🙂
Posted in ASP.NET | Tagged: .NET, ASP.NET, Vakul, Vakul Kumar, Vakul Kumar More, VB.NET, Visual Studio 2008, Visual Studio 2010 | Leave a Comment »
Posted by Vakul Kumar More on July 6, 2011
I was approached by a colleague recently about an error related to “SGEN.EXE” when tried to build the project in release mode. This error is only for the release mode and in debug mode it works perfectly.
I researched further on the error:
Sgen.exe is an XML Serializer Generator Tool used to create an assembly for types in a specified assembly in order to improve the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types.
Sgen.exe generates the [libraryname].XmlSerializers.dll and will be used by the clients of webservices to speed up the time to load the webservice.
- Right click on the project and in the properties page of the project, click on the Build tab.
Select Configuration: Release.
At the bottom, Generate serialization assembly is set to AUTO. When it is AUTO in release mode, SGEN tries to create XML serialization assembly and fails. Set Generate serialization assembly to OFF. If it is set to OFF, Visual Studio never runs sgen.exe.
- Copy the sgen.exe file from C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ to C:\WINDOWS\Microsoft.NET\Framework\v3.5\. I’m not sure if this is 100% solution.
- Open the GAC (C:\Windows\Assembly), find the DLL corresponding to your project.
- Right click on it and select uninstall.
- Now, re-build your project and the problem must be gone.
- Final solution would be to try refreshing from SourceSafe and if it wont solve the problem would be to destroy entire solution hierarchy and get a fresh version of solution to a new location.
I’m sure the first solution should solve the problem, 2nd and 3rd solution can be tried to solve the error.
Let me know if there is anything can be added in comments section.
My short bio
Posted in ASP.NET, Technical, Tips & Tricks | Tagged: ASP.NET, serialization, sgen, sgen.exe, Vakul, Vakul Kumar, Vakul Kumar More, Visual Studio 2008, Visual Studio 2008 Debugger | Leave a Comment »
Posted by Vakul Kumar More on April 13, 2011
From the early days of using ASP.NET, we use Server.Transfer(URL) and Response.Redirect(URL). These simple calls used in ASP would never create problems but, in ASP.NET an exception is thrown when used.
The ThreadAbortException is thrown when a call is made to Response.Redirect(url). This happens because the system aborts processing of the current web page thread after it sends the redirect to the response stream. Internally, Response.Redirect(url) makes a call to Response.End() and that call Thread.Abort() which forces the stack to end the thread.
Many suggest using Try and Catch block. I feel it may not be a proper solution as processing exception can be costly. Best option would be to use an overload method of Response.Redirect() to redirect without calling Response.End().
Response.Redirect(string url, bool endResponse);
Response.Redirect(url, true) – The client will be sent the redirect for the new page and present page will immediately stop processing as a thread abort will occur. This is the default behavior of a redirect.
Response.Redirect(url, false) – In this overload method, the second parameter tells the system whether to make the internal call to Response.End() or not. Parameter should be false to make the client is sent to redirect url but call to Response.End is skipped. This is one way to avoid the exception, but the cost is that this thread doesn’t stop executing the Application events!
If you are doing a redirect in Page_Init (or any page events) and call Response.Redirect(url, false) the page will only redirect once the current page is done executing. This means that any server side processing you are performing on that page WILL get executed.
Though, there are cons of using both methods I personally prefer using Respose.Redirect(url,false).
My short bio
Posted in ASP.NET | Tagged: ASP.NET, false), Response.Redirect(url), Server.Execute, Server.Transfer, ThreadAbortException, Vakul, Vakul Kumar, Vakul Kumar More, Visual Studio 2008, Visual Studio 2010 | 4 Comments »