Thursday, 19 July 2012

Issue with installing IIS after Visual Studio

If you install IIS after Visual studio, most of the time you will run into below mentioned error because IIS settings have not been correctly configured and accessing files with extension like .svc will throw this.:


This is simple to fix, Just open the visual studio command prompt and run the below command :

aspnet_regiis.exe -i

This should fix the issue.

Thanks!!

Deploying a WCF Service in IIS Without an .svc File



The .svc file is a special content file that IIS uses to recognize a WCF service. It provides
the information that the hosting environment in IIS uses to activate the WCF runtime
and start the service. The .svc file always forms part of the address of a WCF service
hosted by using IIS (this is not the case with other hosting environments).
WCF 4.0 provides a feature called Configuration-Based Activation, with which you can
combine the information normally included in the .svc file directly into the Web.config
file for a WCF service hosted by IIS. To do this, you add a <serviceActivations> section to
the <serviceHostingEnvironment> part of the configuration file and provide values for
the relativeAddress and service elements. The relativeAddress element should be a string
that looks like a filename with the .svc extension, and the service element should specify
the fully qualified type that implements the WCF service. The following code fragment
shows an example that configures the ProductsService WCF service:
<?xml version=”1.0″?>
<configuration>

<system.serviceModel>

<serviceHostingEnvironment multipleSiteBindingsEnabled=”true”>
<serviceActivations>
<add relativeAddress=”NoServiceFile.svc”
service=”Products.ProductsServiceImpl” />
</servicaActivations>
</serviceHostingEnvironment>
</system.serviceModel>

</configuration>

Wednesday, 18 July 2012

Export DataView to DataTable


A DataView object can be used to export data from one DataTable object to another. This will be especially useful when a user-defined set of filters is applied and the user wants to convert the view that is seen into a new data table. Exporting to a new data table is done with the DataView object’s ToTable method, For e.g.

DataTable export = view.ToTable(
"MyTable", true, "CoulmnA", "ColumnB", "ColumnC");

This code sample exports the data seen through the data view called “view” to a new
DataTable object named export. Note that the name of this table is “MyTable”. Passingtrue for the distinct parameter indicates that only distinct values are kept (which filter out duplicate values). If false is used, all values should be shown. The names of the columns to include in the new table are then passed to the method.