Thursday, 28 May 2015

8 Ignite 2015 sessions for .Net Enthusiasts

Microsoft Ignite 2015 demonstrated lots of innovation Microsoft is putting in various technologies and its products. There were hundreds of sessions which seems like a must watch, however due to time constraints it is not possible to go through each and every one of them.
To help out Dot Net community out here I handpicked 8 Ignite 2015 sessions for Dot Net enthusiast to get the taste of next versions of .Net related technologies.
1.       A Lap around .NET 2015: .NET 2015 is the next generation of .NET. This release encompasses several new innovations that improve developer productivity and enhance application performance. .NET 2015 builds on the advancements available in Microsoft .NET Framework 4.5, 4.5.1 and 4.5.2 to deliver a highly compatible platform for building applications for the mobile-first, cloud-first world. This presentation includes .NET Native, ASP.NET 5, C# 6, the new .NET compiler platform, numerous IDE improvements as well as new features in Windows Presentation Framework.

2.        What's New in C# 6.0 and Visual Basic 14: C# 6.0 and Visual Basic 14 both add a number of bite-sized new features, all aimed at making your everyday code cleaner and clearer. Instead of introducing new concepts, each feature makes a common coding pattern simpler, and removes boilerplate to let the intent of the code stand out. In this session, we walk you through all of these language features: interpolated strings, a nameof operator, an operator called Elvis, and many more.

3.       Introduction to Microsoft ASP.NET 5: ASP.NET 5 is a landmark release in many ways. It’s full open source from the start, it’s cross-platform and supported on Windows, Mac, and Linux. It includes contributions from the community and is being developed in the open on GitHub. ASP.NET 5 includes lots of great updates as well like TagHelpers, the unification of MVC and Web API, the componentization of the .NET Framework, dependency injection built in, an all-new project system, and deep client-side tooling for things like Bower, Gulp, and Grunt. This is an exciting time for the Microsoft web platform.

4.       Deep Dive into Microsoft ASP.NET 5: ASP.NET 5 has an all-new project system and cross-platform runtime. In this session, we dig deep into the "what, how, and why" of ASP.NET 5. We look at how you can deploy your own version of the .NET.

5.        Debugger Tips and Tricks for .NET Developers with Microsoft Visual Studio 2015: Come to this all-demo session to learn how to make the most of the Visual Studio debugger. We tour almost all of the debugger, throwing in tips and tricks as we go along, and also calling out what's brand new in the latest version of the debugger in Visual Studio 2015. Whatever your experience level, we guarantee you'll learn something new!
6.        C# and Visual Basic Code-Focused Development with Microsoft Visual Studio 2015: Visual Studio 2015 is productivity game changer for C# and Visual Basic! The .NET Compiler Platform ("Roslyn") enables many new experiences that will change the way you write and debug code. In this session, we dig into the new features that bring a new level of awesome to the C#/Visual Basic IDE experience and explore many existing features have been completely refreshed. Come learn about new refactoring support, major debugging enhancements, code aware frameworks, and much more!

7.        Microsoft Visual Studio for Web Developers: Learn how Visual Studio 2015 integrates with popular modern web tools and client-side frameworks to provide a better and more powerful development experience than ever. Join Mads as he walks you through the use of Gulp, Bower and npm and see how Visual Studio 2015 works with these tools to bring new and better workflows to web development.

8.        The SQL Server Evolution: Everything you want to know about next-generation SQL Server, mission critical performance and scale for transactional, data warehouse and mixed workloads, structured and unstructured data, security innovations, availability and reliability improvements, advanced analytics, business intelligence, world class scale on-prem and to the cloud.


Wednesday, 11 December 2013

SharePoint 2010 Sandbox solution 3 – Sandbox Proxy


As now we are aware of architecture and execution model of Sandboxed solutions, this blog should be dedicated to a sample sandbox solution. Do you think it is required? I don’t think so because it’s a very straight forward task which doesn’t motivates me to dedicate a full blog J. Instead we’ll take another topic – Sandbox Proxy or Full Trust Proxy.

If you want to execute full trust code in a sandbox solution then the only way of doing so is to write a Sandbox Proxy.



A sandbox proxy must be registered to User Code Host Service so that it can be called from a sandbox solution. Below are the steps to create and register a proxy

Step 1: Create SP Project


1.      Create an Empty  SharePoint Project

2.      Update the AssemblyInfo class and add following attribute to the class

 

using Microsoft.SharePoint.UserCode;

 

Step 2: Create Argument Class


1.      Add a new class “TestProxyArgs” with public access modifier

2.      Add following

using Microsoft.SharePoint.UserCode

 

3.      Make the class serializable and inherit from SPProxyOperationArgs class as following

[serializable]
public class TestProxyArgs : SPProxyOperationArgs { }

 

4.      Add properties that you want to pass from the proxy. Only serializable types can be used as properties here

public string TestArg { get; set; }
 

5.      Add read-only properties for the type name and assembly name of the proxy operations class (which we will create in the next step). This is required in registering the proxy operation and when invoking the operation from sandboxed code. By adding these properties to the proxy arguments class, we ensure that they are available from all locations when required.

6.      Add read-only properties for the type name and assembly name of the proxy operations class. The type name should be fully qualified and the assembly name should be the four-part strong name of the assembly

public static string ProxyOperationTypeName
{
  get
  {
    return "TestProxy.TestProxyOps";
  }
}
 
public static string ProxyAssemblyName
{
  get
  {
    return "TestProxy, Version=1.0.0.0, Culture=neutral,   
            PublicKeyToken=2dfe43bced7458f6";
  }
}

Step 3: Create Proxy Operations Class


1.      Add a new class named TestProxyOps to the project with a Execute method as following
public class TestProxyOps : SPProxyOperation {
public override object Execute (SPProxyOperationArgs args)
{
}
        }
 

2.      In the Execute method, cast the SPProxyOperationsArgs parameter to your proxy operations argument type, which in this case is TestProxyArgs.

   var proxyArgs = args as TestProxyArgs;

 

3.      Retrieve the arguments from the proxy arguments class and perform any full-trust logic

// Retrieve arguments from the proxy arguments class.
string testArg = proxyArgs.TestArg;
 
// Perform full-trust logic; for example, call a WCF service.
FullTrustMethod(testArg);
 
 

 

Step 4: Register Proxy Operation


  1. Add a new feature named TestProxyFeature to the project
  2. Make the scope of the feature to Farm
  3. Add an event receiver to the TestProxyFeature
  4. Add the following using statements to the TestProxyFeature.EventReceiver class

using Microsoft.SharePoint.Administration;

using Microsoft.SharePoint.UserCode;

 

  1. Uncomment the FeatureActivated method.
  2. In the FeatureActivated method, add the following code to retrieve the local user code service

SPUserCodeService userCodeService = SPUserCodeService.Local;

 

  1. Add the following code to create a new proxy operation type, based on your proxy operation class

var TestOperation = new SPProxyOperationType(

                            TestProxyArgs.ProxyAssemblyName,

                            TestProxyArgs.ProxyOperationTypeName);

 

  1. Add the following code to register your proxy operation type with the local user code service.

userCodeService.ProxyOperationTypes.Add(TestOperation);

userCodeService.Update();

 

  1. Deploy your sandbox proxy to the test environment.

Step 5: Use the proxy from Sandbox solution


  1. In the sandboxed solution, add a reference to the sandbox proxy assembly
  2. Create an instance o­f the proxy arguments class and set any property values

var proxyArgs = new TestProxyArgs();

proxyArgs. TestArg = "Test Arg";

 

  1. Call the SPUtility.ExecuteRegisteredProxyOperation method, passing in the assembly name of the proxy operation, the type name of the proxy operations class, and the proxy arguments instance. In this case, the assembly name and the type name are provided by static properties of the proxy arguments class, as described in step 2.

var result = SPUtility.ExecuteRegisteredProxyOperation(

 TestProxyArgs.ProxyAssemblyName,

 TestProxyArgs.ProxyOperationTypeName,

 proxyArgs);

 

That’s it. Hope this would help you guys J
Please note that I posted this blog orignally on http://aspe-it.com/blog/2013/sharepoint-2010-sandbox-solution-3-sandbox-proxy/

SharePoint 2010 Sandbox solution 4 – Solution Validation


 

The scope of a sandboxed solution is site collection and site collection administrator can activate / deactivate it. There may be some cases where the farm administrator needs to have a check before activating the solution. For such purpose Sandbox Solution Validator is used. In this episode of Sandbox solution, we will look at HOW TO IMPLEMENT SANDBOX SOLUTION VALIDATOR. Although it’s a feature which is not used often, I am still taking it up as I know how handy it can be proved when you really need to implement a rule for solution activation.

To create a solution validator you need to follow below steps

1.      Create an empty SharePoint Farm solution in VS

2.      Add a class SolutionValidator  in class file SolutionValidator.cs

3.      Inherit it from SPSolutionValidator and give a GUID to the class

 

    [Guid("DAC77CB7-7511-4E7E-8427-B6A57C5F49F7")]

    public class SolutionValidator : SPSolutionValidator

    {

    }

 

4.      Give name to the validator by defining a property in the validator class

 

private const string validatorName = "Custom Solution Validator";

 

5.      Add constructors

 

public SolutionValidator() { }

    

public SolutionValidator(SPUserCodeService userCodeService) : base(validatorName, userCodeService)

       {

           this.Signature = 1111;

      }

 

6.      Override ValidateSolution method and set the properties.Valid as true or false based on your logic. If properties.Valid is false then SCA wouldn’t be able to activate the solution

 

public override void ValidateSolution(SPSolutionValidationProperties properties)

       {

           base.ValidateSolution(properties);

   

           // Write some validation logic here an

           //properties.Valid = true;

}

 

7.      Override ValidateAssembly method and set the properties.Valid as true or false based on your logic. If properties.Valid is false then SCA wouldn’t be able to activate the solution

 

public override void ValidateAssembly(SPSolutionValidationProperties properties, SPSolutionFile assembly)

       {

                // Write some validation logic here an

           //properties.Valid = true; 

       }

 

Is it done? The answer is yes and no. The validator is ready but it is not registered yet. To register the validator to SPUC service, add following code in FeatureActivated method of the feature in which this class is added

 

SPUserCodeService sandboxService = SPUserCodeService.Local;

            SPSolutionValidator solutionValidator =

                    new SolutionValidator(sandboxService);

            sandboxService.SolutionValidators.Add(solutionValidator);

 

To unregister the validator add following code in FeatureDeactivating method

 

SPUserCodeService sandboxService = SPUserCodeService.Local;

Guid solutionValidatorId = sandboxService.SolutionValidators["Custom Solution Validator"].Id;

sandboxService.SolutionValidators.Remove(solutionValidatorId);

 

Now deploy the solution and try to activate any sandbox solution in solution gallery. You should be able to see the rules/ logic,  you wrote in validator, governing the solution activation. Enjoy J

Please Note that I posted this blog orignally on http://aspe-it.com/blog/2013/sharepoint-2010-sandbox-solution-4-solution-validation/