Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Saturday, January 14, 2012

Testing with Visual Studio 2010

The last time I am discovering more and more the test features of Visual Studio 2010. In this blog item I discuss or mention some of these features.

It is possible to execute a code analysis after each developer build. You can enable (or disable) this in the properties of the project; see tab Code Analysis. There are several rules you can configure (globalization rules, basic correctness or of course you can customize these)
It is also possible to measure the quality of the code, with Code Metrics. Code metrics gives some overview in maintanability and complexibility. The code metrics can be used to give a progress overview in a refactor proces to the management, simply export this data to Excel. The index for maintability, complexibility, depth, code coupling and lines of code.
With the Test Impact Analysis feature Visual Studio shows you the tests which are affected on the code change. (use the Test Impace Window)
There are several tests; Code UI Test, Load Test and Web Performance test. You can also use profiling for your application. You can select CPU Samples, Instrucmentation and compare the results and find the method or class which is the most expensive.

Monday, October 18, 2010

Public token key

With the 'sn.exe' tool of Visual Studio it is possible to retrieve the public token key. But watch for the casing!!

Use the command: sn.exe -Tp "FilePath to assembly"

Tuesday, October 12, 2010

Fiddler and localhost

Working with Fiddler for seeing the details of the Http request of a website is usefull for optimizing the performance of a website. Check if there are unneeded requests or if there are many requests which triggers a 404.

A tip when working with localhost you must http://localhost.:1519/default.aspx instead of
http://localhost:1519/default.aspx. So add a point behind the hostname.

IEnumerable Empty

When creating an IEnumerables, I mostly returned a null value when there are no values for the collection. But it is in some situations better to return an empty collection. This can be done with the Enumerable.Empty method.

Wednesday, May 19, 2010

How to take ScreenShot in C#

From this article I have copied the code below for taking a screenshot. I have not yet tested this code, because I do not reminder where I need this... when I do I will update this post:)

here is the code in C# for screenshot.

int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);

Friday, April 30, 2010

.NET Framework 4

Since the beginning of this month is .NET Framework 4 released. When migrating to a newer version of the framework, there are always some issues. These issues are listed on the MSDN site. Hope it helps!

Update: Some changes from another view

Thursday, March 25, 2010

Embedded Resources

When you work with embedded resource, you can use the following code to get a list of all the embedded resources in de current assembly:

foreach (string s in this.GetType().Assembly.GetManifestResourceNames())
System.Diagnostics.Debug.WriteLine(s);


More info on How to use assemlby embedded resources

Friday, March 12, 2010

Check your web.config

Check your web.config on these common mistakes which occurs in the web.configs.

IIS 7 and IIS 7.5

The IIS version for Windows Server 2008 (Vista) is IIS7 and the IIS version for Windows Server 2008 R2 (Windows 7) is IIS 7.5. read more information about specific details. At the moment it is not clear for me what the difference are for configuring a web application in IIS 7 and IIS7.5, specially for the web.config. When I know more about this, I will blog this....

Monday, February 8, 2010

Taking Shapshots in ASP.NET

On the blog of ENES TAYLAN I have found an article about Taking Shapshots in ASP.NET. It is a nice feature, but it must be provided as webservice, in the example on this page it can only be used a stand-alone.

Which exceptions are there in .NET?

On the blog of Mikesdotnetting there is a article which summaries some exceptions from the .NET Framework. So these can be used.

Monday, February 1, 2010

How to get an indexed item of an IEnumerable object (Linq)

How to get an indexed item of an IEnumerable object (Linq), this is a question which I often have had when I start using IEnumerable. But it is possible with the ElementAt() extension method!.

Friday, January 22, 2010

Get the name of the method

Sometimes it is easy to print the methodname of the current method. This can be typed manually, but with use of Reflection this can be retrieved with the following simple command:

System.Reflection.MethodBase.GetCurrentMethod().Name