DarioSantarelli.Blog(this);

Archive for September, 2007

WCF: Service Hosting in WAS

Posted by dariosantarelli on September 29, 2007


A WCF service is a program and  can run as a stand-alone executable (like Console and Windows Forms applications) . This scenario is known as a self-hosted service.  Moreover, WCF services can also be hosted  in external agents, such as IIS or Windows Activation Service (WAS ),  implemented as a Windows service in Windows Vista.
Alternatively, a service can also be run automatically as a Windows service.  Finally, COM+ components can also be hosted as WCF services.
For more info about WCF architecture go to this link : http://msdn2.microsoft.com/en-us/library/ms733128.aspx
Above all, the WAS hosting is the real new feature because it provides a concept that extends the ASP.NET HTTP hosting concept (ASMX Web Services).  As a standalone Windows component, WAS  it’s completely separated from the IIS hosting environment and provides a protocol-agnostic activation mechanism, so you aren’t limited only to HTTP.
WAS allows you to choose the most appropriate protocol for your needs:

  • for the HTTP protocol, data transfer relies on the ASP.NET HTTP
  • for non-HTTP protocols such as TCP and Named Pipes, WAS leverages the extensibility points of ASP.NET for transferring data. 

 These capabilities are implemented in the form of protocol handlers which manage communication between the worker process and the Windows service . There are two types of protocol handlers loaded when the WAS activates a worker process instance: Process Protocol Handler (PPH) and App Domain Protocol Handler (ADPH).
If you are interested in practice hosting WCF services, you can find a great tutorial in this article: Hosting WCF Services in Windows Activation Service.

Posted in WCF | Tagged: , , | Leave a Comment »

Sql Server 2005 Management: How to programmatically find the original logical DataBase name from a backup file

Posted by dariosantarelli on September 14, 2007


To retrieve the original logical DB Name from a Backup file (es. .bak), you just have to call the RestoreFileList(…) method from a Restore class instance, naturally after adding a file Device. This method returns a DataTable containing a row for each added device. So, each datarow contains some metadata, including the original logical DB name, which can be found on the first column:

using System.Data;
using Microsoft.SqlServer.Management.Smo;

Server SQLServerInstance = new Server(“MyServer\\MyInstance”);
Restore restore = new Restore();                                               
restore.Devices.AddDevice(“BackupFile.bak”, DeviceType.File);
DataTable RestoreInfoDT = restore.ReadFileList(SQLServerInstance);
DataRow drow = RestoreInfoDT.Rows[0];               
restore.Database = RestoreInfoDT.Rows[0][0].ToString();  // Retrieves the original logical DB name   
restore.SqlRestore(SQLServerInstance);

Posted in .NET Framework, C#, Microsoft Technology | 1 Comment »

C# Language Specifications 3.0

Posted by dariosantarelli on September 10, 2007


I’d like to advice this page (MSDN) where you can find the unified C# Language Specification which covers all the features of the C# language through version 3.0 (just 500 pages!!!)… In this document there are a lot of interesting and not so broadly known features (e.g. atomic operations on integral types like ulong). I think just a quick look will be fine in order to discover some curiosities ;).

P.S.: To people thinking C# as a not standard language, please read the Introduction:

… C# is standardized by ECMA International as the ECMA-334 standard and by ISO/IEC as the ISO/IEC 23270 standard. Microsoft’s C# compiler for the .NET Framework is a conforming implementation of both of these standards…

Posted in .NET Framework, C#, Microsoft Technology | 1 Comment »

LINQPad (Beta)

Posted by dariosantarelli on September 5, 2007


Oh my God!!!!
Now you can download LINQPad (Beta), a very useful tool for experimenting LINQ technology!!!!
It supports LINQ to objects, LINQ to SQL and LINQ to XML.
GREAT!!!

Posted in .NET Framework, Microsoft Technology | Leave a Comment »

Getting a DataRow from a DataGridViewRow

Posted by dariosantarelli on September 5, 2007


If you want to retrieve a DataRow from a DataGridViewRow (for example starting from a DataGridViewSelectedRowCollection), you simply need to get the Row property of the DataRowView obtained by converting the DataBoundItem object of the DataGridViewRow :

DataGridViewSelectedRowCollection rows = MyDataGridView.SelectedRows;               
foreach (DataGridViewRow row in rows)
{
 
DataRow myRow = (row.DataBoundItem as DataRowView).Row;
 
// do something with your DataRow…
}

Hope it helps 😉

Posted in .NET Framework, C#, Programming | 17 Comments »