Well for starters let me assume you are a poor dev like me and don’t have access to Resharper! Well in case you do they have a lot of these features that are now available free of cost in Productivity Tools in VisualStudioGallery.msdn.microsoft.com.
Let me quickly show you some of the features that stand out pretty instantaneously .
1.PresentOn/Off – type this into the quick launch and lo you get the power of zoomit 🙂
2.You can now edit a project file by right clicking on the project.
3.Browse to definition by pressing on control and left mouse click.
4.Email code snippets by using the same option in context menu.
5.Now you can find duplicate code snippets by selecting the option “Find Matching clones in solution” in context menu.
Also there are other features like Auto Brace Completion,Open Command Prompt and HTML copy.
So go ahead and give it a download!!
Well most often MS doesn’t setup stuff .So you have to do it for yourself.Like for Load testing in VS test cases,
you have to configure the database “LoadTest2010” and the corresponding tables like LoadTestRun,LoadTestCase,…
Well this is how you can do it in case you stuck at it.
Browse to this folder and execute in command line else you can always run the script in Management Studio.
cd “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE”
SQLCMD /S localhost\sqlserver -i loadtestresultsrepository.sql
Well this one was pretty nasty I must admit.I didn’t know that I would lose some time on this one.And since I did I might as well blog about it.So here goes the problem statement.Have you faced the scenario wherein you had to copy some files under some folder in Unit tests in Visual Studio? This is because the test cases run under a folder called test results and each time you run it creates a new folder for that particular test case. Mind you before I start I must say that I have encountered this on the VS-2010 and not on the nascent versions of Visual Studio viz 2012.So here goes as to what you need to do to achieve the same.
1)First go the TestSettings file in VS 2010 which is directly under solution.
2)Go to Deployment section and check Enable deployment and add the directory that you want to add.
3)Now is the trick part you have to edit the Test Settings file in Xml editor and go the tag under Deployment which has the required DeploymentItem and the attribute outputDirectory as follows.
4)Finally the worst part was now when you run the unit tests you will still now find it added.So to get it in working in VS 2010 you have to select the test list editor under the Test–>Windows menu in Visual Studio IDE.And then select your tests and hit run.Eureka… ooo still not there yet.The directory or file is still not out there!
5)Close your Visual Studio IDE and open it once again.(Age old trick works in the realm of WINDOWS).
So happy testing once again 🙂
I was recently working with xmls and xsd’s and came across this wonderful utility called XSD.exe.Using this you can create classes or xmls from schema’s and viceversa as well.Wonderful aint it?
Generate classes from a given xsd
C:\classfiles>xsd “C:\SampleServices\Item\Lookup.xsd” /classes
For more info go to the path where xsd is(mine is C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools or C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64.This location is for VS2010 as you would have already presumed) in the command prompt is and hit
And did you know you can even generate schema for a type from a dll or exe.. Cool eh?!
There has many a time that i have posted on tools, that makes life so much simpler,in order that we can can have the extra time to fall in love with C#!So many of us hate to see Xml. Lets admit it ,not many are in awe of the beauty called xml and have burnt their fingers and are not comfortable with it.But next time when you hear that you have to create a custom configuration,don’t fear as we have tools in place to handle that.Thanks to the wonderful tool called Configuration Section Designer.I wouldn’t have ventured into it had not i made a silly mistake which took my entire day and i began to question the logic of creating all these with mere hands and why not get it automated?
You can install the Configuration Section Designer from here.Once you download the plug-in and install it ,it fits perfectly well with VS-2008. and VS-2010 folks ,your version is yet to be out.But once you have installed the Custom Configuration Designer you can see that you will get a project like the snapshot available for you to play around!
Once you have created the Custom Configuration ,you will get a default custom Section designer diagram which will be empty .Go to the properties and enter the values in Namespace and XmlSchemaNamespace as follows.
Once you are done naming your namespace as well as the xml schema namespace, you can go ahead and drag and drop the Config Section, Config Section Group, Configuration Collection as well as Configuration Element.Here is sample that I have created.Its really simple isn’t it?
And you can add custom classes to the existing predefined system types for your elements as well as the attributes as well as mention if it required and to make a certain attribute Key for a Config Collection.And then all you need to do is build it .
Recently i came across a situation wherein i had to host a WCF service as a Windows Service.Only after i installed the service using InstallUtil –i “assembly name”,did i realize my folly that i had a misconception regarding the term “Automatic”.What i am referring to the ServiceInstaller.StartType property.The main intent of this property is to start the Service automatically on start of Windows.
- this.serviceInstaller1.StartType =
So what do i do in run the service while installation?All you need to do add the event AfterInstall for the ServiceInstaller and then call the ServiceController from the eventhandler to start the service.
- public partial class ServiceInstaller : Installer
- public ServiceInstaller()
- ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
- ServiceInstaller serviceInstaller = new ServiceInstaller();
- //Specifies the type of account that should be used for the service.
- processInstaller.Account = ServiceAccount.LocalSystem;
- //Specifies the name of the service that is installed.
- serviceInstaller.DisplayName = "Josh Service";
- //Gives the description of the Installed service.
- serviceInstaller.Description = "this is a Win Service";
- //It tells which is the service that should be installed.
- serviceInstaller.ServiceName = "MyService";
- //It specifies the Start type of the service.
- serviceInstaller.StartType = ServiceStartMode.Automatic;
- this.AfterInstall += new InstallEventHandler(ServiceInstaller_AfterInstall);
- void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
- ServiceController sc = new ServiceController("MyService");
“The service on local computer started and then stopped. Some Services stop automatically if they are not in use by another services or programs.”
You are all used to debugging and would have most likely than not used the “attach to process ” to debug your service implementation.But what do you do when you get Errors or have to debug the Windows Service installer itself?Bingo, we can always write “System.Diagnostics.Debugger.Launch();” in the OnStart() method and start debugging.Also you can write the errors to the EventLog or dump the Exception to a Log after putting in place a simple try catch!