Friday, June 14, 2013

Steps to Host WCF on Window 8

Step 01 :

Goto C:\Windows\System32\inetsrv\config\applicationHost
 then change this section of the application host file (Deny to Allow)
 <section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />


Step 02 :

Goto control panel - Programe and features - Turn window feature on or off
and change checked the following things.

       


Step 03 :

Run this command
C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe –i

By performing these three steps you will be able to host the WCF on window 8 / IIS 8

ThankYou.




Tuesday, May 21, 2013

How to Create WCF Services with Multiple Endpoints and Bindings in visual studio 2012

step 1-------------------------------------------
Create new WCF Application
File-New-Project-WCF Service Application


Step2-----------------------------------------------------
Delete the created files Service1 and IService1 from the project

Step3- ----------------------------------------------------
right click on the project add-new item-WCF service and give it a proper name

after adding this service two file are created in the project one is  IMultipleBindingService.cs interface



[ServiceContract]
    public interface IMultipleBindingService
    {
        [OperationContract]
        void DoWork();
    }



another is MultipleBindingService.svc



public class MultipleBindingService : IMultipleBindingService
    {
        public void DoWork()
        {
        }
    }




Step4---------------------------------------------------------
just make some changes in the IMultipleBindingService.cs


[ServiceContract]
    public interface IMultipleBindingService
    {
        [OperationContract]
        string GetDate();
    }


 and in MultipleBindingService.svc


public class MultipleBindingService : IMultipleBindingService
    {
        public string GetDate()
        {
            return DateTime.Now.ToString();
        }
    }

Step5-----------------------------------------------------------------
Now we created the service that return us a current date time  Lets expose this service through multiple endpoints and bindings

in web.config we configure two endpoints one for Basichttp Binding and other for WSHttpBinding


<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MultipleWcfService.MultipleBindingService" behaviorConfiguration="Mg">
        <endpoint name="BasicHTTPBinding" address="/BasicHttpBinding" binding="basicHttpBinding" contract="MultipleWcfService.IMultipleBindingService" />
        <endpoint name="WSHTTPBinding" address="/wsHttpBinding" binding="wsHttpBinding" contract="MultipleWcfService.IMultipleBindingService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:49714/MultipleBindingService.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Mg">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>


Step6------------------------------------------------------------------

Right Click on the solution and add-new Project- Select Console Application



after creating the Console application right click on the references and add service reference

give the service address and press ok.

Step7----------------------------------------------------------------------

access the service in the client by both endpoints by their name


 static void Main(string[] args)

        {
            MultipleBindingServiceClient proxy = null;
            //BasicHTTPBinding
            proxy = new MultipleBindingServiceClient("BasicHTTPBinding");
            Console.WriteLine(proxy.GetDate());

            //WSHTTPBinding
            proxy = new MultipleBindingServiceClient("WSHTTPBinding");
            Console.WriteLine(proxy.GetDate());
        }


hopefully this post is helpfull for you thanks












Thursday, March 14, 2013

DataRow.Delete Is Not Equal To DataRows.Remove() OR DataRows.RemoveAt()

DataRow.Delete() VS DataRows.Remove() or RemoveAt()

==============================================================
Important Namespaces: 
- System.Data.Sql
-System.Data.SqlClient
==============================================================
Facing an issue inside one of my projects, i was trying to iterate through the datatable datarows and while i was iterating i was removing datarows using a loop index which was going from 0 upto row count of datatable. But i was constantly facing an error. 

"collection was modified. Enumeration operation might not execute."

There i got the difference. I was using DataRows.Remove() or DataRows.Removeat(). Both function remove the datarow physically and committedly from the datatable which was being used in that loop meanwhile. Now important thing is that you cannot mantain the same count of the rows if you are inside the loop and you are using DataTable.rows.count for iteration condition. 

BUT 

Instead you should use the DataRow.Delete() function. Delete() function will not physically delete the row from datatable. It will mark the row to be deleted or update the rowstate as RowState.deleted. The change will not be committed until you call Datatable.acceptchanges() function. 

Now whatever you do with your datatable it will not commit your changes until you call Acceptchanges() function. 



Thursday, February 21, 2013

Windows shortcut commands

Hello everyone, Today I will share windows shortcut commands on a single place, this will hopefully help everyone in our daily activities

appwiz.cpl    It will open control panel

msconfig    open system configuration

ncpa.cpl     open network settings

eventvwr     open event viewer

inetmgr        open IIS

iisreset           reset IIS

services.msc for opening services console

profiler90    opening sql profile

installutil -i path  for installing (eds) service with visual studio command prompt

regedit    for opening registry editor

dxdiag    opening system diagnostic

msinfo32   open System information

taskmgr opening task manager

mspaint for opening paint

mstsc   Remote Desktop

mmc    open micrososft management console

devmgmt.msc  open device manager  

perfmon   open perfomance monitor

gpedit.msc  Grop policy

compmgmt.msc  open computer management  

%windir%\system32\MdSched.exe   windows memory diagnostics 

%windir%\system32\odbcad32.exe    data sources (ODBC)

printmanagement.msc             open printer management

wmimgmt.msc  open Windows Management Infrastructure (WMI)  

lusrmgr.msc open Local Users and Groups  

certmgr.msc  open certificates  manager

Deleting Services from service Console

Create a new process to the call the "sc.exe" with the parameters as below:

sc.exe delete [service name] 


Thank You....
Earn Money ! Affiliate Program
Open Directory Project at dmoz.org