February 2011 - Posts
Convert Visual studio Web
site to VS Web Application project
At the customer I work for there are several
applications written as a web site instead of
Asp.Net web application project . The
reason for that is rather old, they’ve used
Visual Studio .Net 2005 before it’s service pack 1
were released, and Asp.Net web application project wasn’t
offered as a project template.
If you need to choose between the two development models, you might want to read this post. However, today most development teams I’ve encountered, doesn’t use the web site
In this post I’m going to demonstrate, in a few steps, hoe to successfully convert
VS-Web Site to VS-Web Application Project.
So, when encounter a VS-web site, how can you convert it?
1. Open new web application project (an empty one if you’re using VS-2010). Unfortunately you cannot convert the web site within itself.
2. Copy the entire project content to the new project.
Do so by marking all root files and folders on the web site (all but Bin and Obj
folders), right click and choose copy from the context menu, go to the new project,
right click and choose paste.
3. Copy references:
For each .dll file in the Bin folder, you should add it as a reference. That’s actually the hardest part in the process because you need to track all sources. The
references can be found on the web site’s property pages, on the references tab.
4.Make sure all code files are compiled:
For all code files (most of them you may find on App_Code folder), make sure that their build action is “Compile”. You may find their build action to be “Content” and then you have to change it.
Note: If for some reason your code doesn’t compile because some code-behind doesn’t know classes within the project, you may have skipped step 4
5. Namespace – Make sure all code files has namespace. Web-Site doesn’t provide
namespace by default, so after copy your code files you should do so.
6. Convert to Web Application:
By right clicking your project and choose “Convert to web application” you will add for each markup file (ASPX, ASCX) a .designer.cs (or designer.vb) file which exists on Web Application Project but doesn’t exist on Web Site.
8. Remove the old Web Site
Note: This post won’t apply for multiple programming languages web sites
SDP is coming soon, and we’re presenting another post on our ETW series. I’m taking the opportunity one again to come and hear Yaniv Rodenski and myself talk about it.
On my previous post I’ve shown how to consume ETW data using Data collector sets. What we’ve done there was setting the grounds for heaving a .etl file with the data we are going to read.
Let’s have another look at part of the code from Yaniv’s post
descriptor = new EventDescriptor(
0x7d1, 0x1, 0x10, 0x0, 0x0, 0x0, (long)0x8000000000000000
Console.WriteLine("Please enter the number of events to be written and
var returns = int.Parse(Console.ReadLine());
for (int i = 0; i < returns; i++)
// we pass the event descriptor by ref and the counter
// as our payload. Please note that the payload is passed
// as params object so we can enjoy some good ol' boxing
provider.WriteEvent(ref descriptor, i);
This is the code section that write the events to our data collector (i.e our .etl file). Let’s see
first how will our .etl file look:
All we need to do is simply double click the file or open it with
Windows Performance analyzer (XperfView) .
The screen will look like that:
The red points collection (which looks like line from here) are the events written to
the .etl file. We can, for our own convenience, select part of the chart and press
“Zoom to selection” as shown below:
After doing so we will see the chart as a collection of points, and now we can have a look at
a single point and understand what an event actually is.
At the tooltip we can see the provider GUID (as being set in Yaniv’s post) along with the
data set in the event descriptor’s (the parameters at it’s contructor).
At the callback (bottom line) we can see number “4” which is the index
sent by our code to the WriteEvent method.
In this post we’ve seen an etl file visualization with XperfView. The file is the data collected
by operating our Data Collectors Set as shown at my previous post . Next I’ll discuss some
more features of XperfView.
ETW – Consuming events
You may or may not have heard about ETW which is a powerful tool for event tracing, which
one of it’s most significant advantages is it’s performance . At the following SDP, You are more than welcome to hear Yaniv Rodenski and myself talk about it.
At this post I will demonstrate how to consume an event written by an application writes this
events. I will do so by creating Data Collector Set .
There are some ready-made providers for CLR, ASP.Net and more, however in order to simplify I’ve chosen to take a manifest-based application. In order to create it
you can read this post which describe how to do so step by step.
Create a data collector
A data collector is a trace listener for ETW that uses one or more ETW provider and writes
it’s / their events to a .etl file.
In order to have the data collector you can use a command line tool called logman or use the computer management tool. In here I’ll demonstrate the computer management tool:
1. Go to Computer management –> Performance –> Data Collector sets –> User defined
2. Write click –> Choose “New” –> Data collector set, this dialog box will open:
3. Name your data collector and choose “Create manually” (and press “Next”)
4. At the next step, choose “Event trace data”
5. After pressing next, we get to choose our provider (or providers)
Here we choose the provider named “ExampleProvider” .
6. Now, back to the provider’s screen, let’s make sure that the trace will capture events with the keyword set for our provider earlier. we do so by pressing the Keyword(any)
property, pressing the “Edit” button and set the value to 0x8000000000000000.
7. Now we can select the event trace log (etl) file location. I’ve left the default
8. You can have the data collector run on different credentials than the default. |
We’ll leave it as is
Now we have our data collector set ready. Now all we have to do is two things:
1. Run it (Right click –> Start)
2. Run our application
We will see a .etl file on the directory we’ve set earlier. This file is
In this post I’ve shown how to create an ETW Data Collector set to consume an ETW Provider. We’ve gone through all steps in defining the data collector set. This process works also for the classic providers already exist.
Next post, we'll dive into the .etl file and read our events.