Wednesday, 4 June 2014

Microsoft.SharePoint.SPEndpointAddressNotFoundException: There are no addresses available for this application.

Microsoft.SharePoint.SPEndpointAddressNotFoundException: There are no addresses available for this application.    at Microsoft.SharePoint.SPRoundRobinServiceLoadBalancer.BeginOperation()     at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.<>c__DisplayClass2f.<RunOnChannel>b__2d()     at Microsoft.Office.Server.Security.SecurityContext.RunAsProcess(...)     at Microsoft.SharePoint.Taxonomy.MetadataWebServiceApplicationProxy.RunOnChannel(...)  .....

The Problem with the above message is caused by the Service Application "Managed Metadata Web Service" and Proxy being configured and started, however The Service On Server Managed Metadata Web Service  not running.

Solution : 

Step 1 : Central Admin -> System Settings  -> Manage Service on Server (Under Servers Heading)
Step 2 : Start "Managed Metadata Web Service".

Now, the Exception will be removed and works fine. In order to use this service, you need to wait for some time because it takes time to apply changes in server level.

Extension for solution : 

The same message might appear in relationship with any service/service application. What you need to do is to check the call stack for the service application name and check the associated service on Server status.

Tuesday, 18 February 2014

Create Group in SharePoint 2010 Programmatically

To Create group in site collection level use the following command:

   string siteUrl = SPContext.Current.Web.Url;
   using (SPSite spsite = new SPSite(siteUrl))
   {
      using (SPWeb web = spsite.OpenWeb())
      {
          web.SiteGroups.Add("GroupName", web.CurrentUser, web.CurrentUser, "GroupDescription");
          web.Update();
      }
   }

To Create group in site level use the following command:

   string siteUrl = SPContext.Current.Web.Url;
   using (SPSite spsite = new SPSite(siteUrl))
   {
      using (SPWeb web = spsite.OpenWeb())
      {
          web.Groups.Add("GroupName", web.CurrentUser, web.CurrentUser, "GroupDescription");
          web.Update();
      }
   }

Thursday, 13 February 2014

How to find public key token for a .NET DLL or assembly

Steps :
1. Go to Start and search for "Visual Studio Command Prompt" and open it.
2. Type the DLL file path and type the following command.
     Command: sn -T myDll.dll

Example: E:\ExampleProject\bin\Debug> sn -T ExampleProject.dll

The output will be as follows:

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Public key token is 4e4ed2e4e49b94ff


Friday, 15 November 2013

How to create Sharepoint List using Client Object Model (JavaScript) ?

To Create a SP List follow the below steps :

Step 1 : Add HTML TextBox and Button fields to HTML file as below.

          <h2>List Creation</h2>
          <table >
            <tr>
               <td>
                    List Name :
               </td>
               <td>
                   <input id="tbList" type="text" />
               </td>
            </tr>
            <tr>
               <td >
                   <input type="button" id="btnCreateList" value="Create List" onclick="CreateList()" />
               </td>
            </tr>
         </table>

Step 2 : Add below Script to create a SPList when you fill Textbox and click 'OK' button.

    <script type="text/javascript">
    var siteUrl = "/";  //give your site url. Ex: sitecollectionTitle/siteTitle
    function CreateList() {
        var listName = document.getElementById("tbList");
        var clientContext = new SP.ClientContext(siteUrl);
        var oWebsite = clientContext.get_web();
        var listCreationInfo = new SP.ListCreationInformation();
        listCreationInfo.set_title(listName.value);
        listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
        var oList = oWebsite.get_lists().add(listCreationInfo);
        clientContext.load(oList);
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }
    function onQuerySucceeded() {
        alert('Request successfully completed');
    }
    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    }
   </script>


Step 3 :  Execute the above code.Enter the list name in the textbox and click button. Now the list gets created.

Enjoy Coding....


Friday, 1 November 2013

Send Email using C#

Add the "System.Net.Mail" namespace at the top of the class and follow the below code to send email using SMTP server.

       public void SendMail()
      {
           try
           {
               MailMessage mail = new MailMessage();
               mail.From = new MailAddress("YourEmailID@gmail.com");
               mail.Bcc.Add("bccEmail@gmail.com");
               mail.CC.Add("sampleEmail@ymail.com");
               mail.To.Add("FriendEmailID@yahoo.com");
               mail.Subject = "Test Mail";
               mail.Body = "Hi...!!! This is a test mail.";
               mail.IsBodyHtml = true;
               SmtpClient smtpClient = new SmtpClient();
               smtpClient.Host = "smtp.gmail.com";
               smtpClient.Port = 587;
               smtpClient.UseDefaultCredentials = false;
               smtpClient.Credentials = new System.Net.NetworkCredential("YourEmailID@gmail.com""YourPassword");
               smtpClient.EnableSsl = true;
               ServicePointManager.ServerCertificateValidationCallback = delegate
               {
                   return true;
               };
               smtpClient.Send(mail);
           }
           catch (Exception ex)
           {
                 //Your Exception code
           }
       }

Total Pageviews