Monday, 14 March 2016

Access on ContentBD for deployment using PoweShell


1. Open PowerShell window "Run as Administrator"
2. put in below script desired SiteCollectionName and UserName whom need to grant permission.



$contentdb = Get-SPContentDatabase -Site http://serverName/sites/siteName
Add-SPShellAdmin -UserName 'domainName\userloginid' -database $contentdb

Thursday, 10 March 2016

Web services/WCF binding on Client Machine




Step 1. Accessing Web services with impersonation Credential 

          1. Add Service reference in Project.
          2. Add Service NameSpace
                     using MyNameSpace.MyNameSpacee;
                         MyNameSpacee.MyWebServiceSoapClient myNameSpacee = new MyWebServiceSoapClient();





Step 2. change the binding in web.config/App.Config like below...



<system.serviceModel>
        <bindings>
            <basicHttpBinding>
              <binding name="MyWebServiceSoap">
                <security mode="TransportCredentialOnly">
                  <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm=""/>
                  <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
              </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address=""
                binding="basicHttpBinding" bindingConfiguration="MyWebServiceSoap"
                contract="MyNameSpace.MyWebServiceSoap" name="MyWebServiceSoap" />
        </client>
    </system.serviceModel>

          3. Add Dynamically Address for current Web

  myNameSpacee.Endpoint.Address = new System.ServiceModel.EndpointAddress(SPContext.Current.Web.Url+"/_layouts/15/MyWebServices/MyWebService.asmx");

OR

Add Static Services Address in

Web.config/App.config like below inside Client Tag

 <client>
            <endpoint address="http://site:port/_layouts/15/MyWebServices/MyWebService.asmx""
                binding="basicHttpBinding" bindingConfiguration="MyWebServiceSoap"
                contract="MyNameSpace.MyWebServiceSoap" name="MyWebServiceSoap" />
        </client>



            myNameSpacee.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
            myNameSpacee.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;



4. finally Call your WebMethod 


myNameSpacee.GetMYMethod();










OutLook Add-In VSTOInstaller.exe.config error while installing Add-in

Error like below 


The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'Microsoft.Office.BusinessApplications.Fba, Version=14.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXX' or one of its dependancies. The system cannot find the file specified. (C:\Program Files (x86)\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe.Config line 10)

or

The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'Microsoft.Office.BusinessApplications.Fba, Version=14.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXX' or one of its dependancies. The system cannot find the file specified. (C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe.Config line 10)


Solution




  • Open Windows Explorer
  • Open the folder C:\Program Files (x86)\Common Files\Microsoft Shared\VSTO\10.0
  • If that folder does not exist, try C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0
  • Rename the file VSTOInstaller.exe to VSTOInstaller.exe.Config

Tuesday, 8 March 2016

GroupBy With LinQ

  var mainQuery = finaldocCount.GroupBy(u => new { u.ProjectCode })
                                                                      .Select(grp => new
                                                                      {

                                                                          ProjectCode = grp.Key.ProjectCode,
                                                                          mailList = grp.ToList()
                                                                      }).ToList();


                          foreach (var item in mainQuery)
                                {
                                    foreach (finalNameCount v in item.mailList)
                                    {

                                        v.Name;


                                   
                                    }
                                }