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....

Friday, February 15, 2013

Deploying File Along With Feature

Few days back, I was working to create an Editor Web Part. The Editor Part contains a drop down and I need to populate it with an XML file (Links.xml) . I had given the file name in XmlDatasource, considering it would be picked, but Editor part gave me an error i.e. file not found.

After doing some research, I came to know a new deployment type ElementFile. This deployment type physically deploy the file along with the feature and we can get the path of the feature then.




SharePoint provides a method for this purpose i.e.. SPUtility.GetGenericSetupPath. By using this method I found my XML file and me editor part started working. I hope this will help any other newbie  in SharePoint..... :)fF

14 HIVE AND OTHER SHAREPOINT 2010 DIRECTORIES


In this post I will list out some important folders used with SharePoint 2010 server. Lets Start with  installation, Configuration and its files, later in the post we will discuss about other 14 hive directories.

C:\Inetpub\wwwroot\wss -
 This directory (or the corresponding directory under the Inetpub root on the server) is used as the default location for IIS Web sites.
C:\ProgramFiles\Microsoft Office Servers\14.0 - This directory is the installation location for SharePoint Server 2010 binaries and data. The directory can be changed during installation.
C:\ProgramFiles\Microsoft Office Servers\14.0\WebServices - This directory is the root directory where SharePoint back-end Web services are hosted, for example, Excel and Search.
C:\ProgramFiles\Microsoft Office Servers\14.0\Data - This directory is the root location where local data is stored, including search indexes.
C:\ProgramFiles\Microsoft Office Servers\14.0\Logs – This directory is the location where the run-time diagnostic logging is generated.

14 hive folders : 


Program Files\Common files\Microsoft Shared\Web Server Extensions\14 -

This directory is the installation directory for core SharePoint Server files.

Program Files\Common files\Microsoft Shared\Web Server Extensions\14\ADMISAPI -

This directory contains the soap services for Central Administration. If this directory is altered, remote site creation and other methods exposed in the service will not function correctly.


Program Files\Common files\Microsoft Shared\Web Server Extensions\14\CONFIG -
This directory contains files used to extend IIS Web sites with SharePoint Server. If this directory or its contents are altered, Web application provisioning will not function correctly.

Program Files\Common files\Microsoft Shared\Web Server Extensions\14\LOGS -

This directory contains setup and run-time tracing logs.
Program Files\Common files\Microsoft Shared\Web Server Extensions\Policy -
Program Files\Common files\Microsoft Shared\Web Server Extensions\UserCode -
This directory contains files used to support your sandboxed solutions.
Program Files\Common files\Microsoft Shared\Web Server Extensions\WebClients -
This directory contains files related to the new Client Object Model.
Program Files\Common files\Microsoft Shared\Web Server Extensions\WebServices -
This directory contains new wcf or .svc related files.
I hope this post will be helpful for you in understanding SharePoint 14  Hive folder hierarchy. Thank You,.

Friday, February 8, 2013

Error occurred in deployment step ‘retract solution’ cannot start service SPUserCodeV4 on this computer


Yesterday I was creating my first SharePoint 2010 Sand-boxed solution using Visual Studio 2010.  I have successfully built and deployed other SharePoint projects on the server but I always used Farm based solution due to the requirements.
When I built the Sand-boxed solution the project would build and package without any errors but when I tried to deploy it to the SharePoint site the following error occurred:
Error occurred in deployment step ‘Activate Features’: Cannot start service SPUserCodeV4 on computer ‘SERVERNAME'
The error can be easily resolved by starting the Microsoft SharePoint Foundation Sandboxed Code Service which can be accessed through the Central Administration site in SharePoint.   Open the Central Administration site and go to System Settings and click on Manage Service on server, as shown below



After starting the service try to deploy the snadoxed solution and the following erros wil be removed. 
"Error occurred in deployment step ‘retract solution’ cannot start service SPUserCodeV4 on this computer"


Thursday, February 7, 2013

This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application


Here is another SharePoint post for the deployment guys. I was deploying a SharePoint solution using SharePoint Admin utility i.e. Stsadm . I started facing error i.e. "This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application"

After analyzing the error message i.e. why I cannot deploy the solution to a web application. However if you do not like to deploy the solution to all the web applications and only like to deploy your solution to a specific application , you need to change the solution settings Assembly Deployment Target from GlobalAssemblyCache to WebApplication.



Change Assembly Deployment Target to Web-application, as shown below





After you change the Assembly Deployment Target and run the script again, you will have the solution deployed successfully. Happy deployment.


Sunday, February 3, 2013

SharePoint Hives Folders

SharePoint has hives folder for all the SharePoint major versions i.e 2007 has 12 hive, 2010 has 14 hive and now SharePoint 2013 has 15 hive folder. Let me elaborate the naming convention that why SharePoint has different hives folder name, then the SharePoint release name.

Basically Hive folder naming convention is development version of SharePoint. As SharePoint team is keep on working on different features of SharePoint all the team, so keep on creating different versions but Hive represent the production version which Microsoft release for SharePoint  I hope this post will help you in understanding why we have different Hive folder naming convention, then SharePoint.

Thank You.

Friday, February 1, 2013

Comments Rendering Issue in Sharepoint

I was working on a custom SharePoint master page, few days ago. After deploying the master page in Gallery, I set it for my site-collection. I had started facing a strange error i..e master tag is already defined. Initially I thought, that SharePoint existing pages, inherited from some other master page and I might override  it, but it also didn't work.

After some time, I started looking my master page html, I had a commented master tag, which I believe should not be rendered by SharePoint, as commented. I removed the commented tag for testing purpose, and surprisingly things starts working. SharePoint engine actually render the commented tag as well.

I hope this post will help any newbie in SharePoint world..... Happy Coding.....:)

Thursday, January 24, 2013

Generating Public key token


Many times we need to get the Public key token for a strongly named assembly in .NET.  “how to get the public key token?”. Answer is very simple use the .NET Framework tools sn.exe. So open the Visual Studio 2008 Command Prompt and then point to the dll’s folder you want to get the public key,

I have used the following command, for generating public key token for a SharePoint project
sn.exe –T SPExcercise1.dll
Public key token is d95388ccbe5ad4c1
This will give you the public key token. 
Remember one thing this only works if the assembly has to be strongly signed.

Monday, January 21, 2013

soap:ServerServer was unable to process request. ---> Value does not fall within the expected range.


In some odd situation, SharePoint Designer (SPD) 2010 would throw this error:
“soap:Server was unable to process request. Value does not fall within the expected range”
Cause
SPD does not open the site with name it was originally defined.  For example, the site was created as http://xyzmachine:9999/, but SPD connects it as http://localhost:9999/
Solution
SPD should connect the site with name/url defined at its creation.
Earn Money ! Affiliate Program
Open Directory Project at dmoz.org