Visual studio feeds

All Visual Studio blogs in one place

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Google+

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Search

PowerShell - Get, Set and Remove environment variables

AddThis Social Bookmark Button

The environment provider made it easy to work with the environment variables on a local machine or a remote server to load the environment as a PSDrive and work on it. This simplifies accessing data from environment variables using PowerShell using the same cmdlets as working with files and directories like Get-Item, Set-Item, Remove-Item etc.
We'll make use of this feature to get, set and remove environment variables.

FunctionTest-EnvironmentPath
{
      [CmdletBinding()]
      param
      (
            [Parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
           
[String]$Path
      )
     
      if(-not ($Path.StartsWith("Env:\")))
      {
            $Path= "Env:\$($Path)"
      }
      Test-Path $Path   
}

FunctionGet-EnvironmentPath
{
      [CmdletBinding()]
      param
      (
            [Parameter(Mandatory = $true)]
            [ValidateNotNullOrEmpty()]
            [String]$Path
      )
   
      if(-not ($Path.StartsWith("Env:\")))
      {
            $Path= "Env:\$($Path)"
      }
     ...(Read whole news on source site)

Visual Studio Toolbox: Historical Debugging with IntelliTrace in Visual Studio 2015

AddThis Social Bookmark Button
IntelliTrace automatically records the execution of your application without you performing any additional steps. Any time the debugger breaks the execution of the application (e.g. because a breakpoint is hit), the IntelliTrace UI is updated and displays the data that has been collected up until that point. In this episode, I am joined by Angelos Petropolous, who was on the show three weeks ago. Angelos returns to show us in more detail the enhancements made to how you use IntelliSense in Visual Studio 2015 for historical debugging.

Buffer Managers, production code and alternative implementations

AddThis Social Bookmark Button
We are porting RavenDB to Linux, and as such, we run into a lot of… interesting issues. Today we run into a really annoying one. We make use of the BufferManager class inside RavenDB to reduce memory allocations. On the .Net side of things, everything works just fine, and we never really had any issues with it. On the Mono side of things, we started getting all sort of weird errors. From ArgumentOutOfRangeException to NullReferenceException to just plain weird stuff. That was the time to dig in and look into what is going on. On the .NET side
of things, BufferManager implementation is based on a selection criteria between large (more than 85Kb) and small buffers. For large buffers, there is a single large pool that is shared among all the users of the pool. For small buffers, the BufferManager uses a pool per active thread as well as a global pool, etc. In fact, looking at the code we see that it is really nice, and a lot of effort has been made to harden it and make it work nicely for many scenarios. The Mono implementation, on the other hand, decides to blithely discard...(Read whole news on source site)

PowerShell script to get the SharePoint version

AddThis Social Bookmark Button

To get which version of SharePoint is installed on the server, you can use the Version property on the SPFarm object. The function below will return the version number or a 0 based on whether SharePoint is installed on the machine or not.

FunctionGet-SharePointVersion
{

      #Add the snapin if not present
      if((Get-PSSnapin|? {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
    {
        Add-PSSnapinMicrosoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    }

      #Get the snapin after adding it
      $snapin= Get-PSSnapin |?{$_.Name -eq "Microsoft.SharePoint.PowerShell"}
      if($snapin-eq $null)
      {
            0
      }
      else
      {
            $snapin.Version.Major
      }
}
/>
To test the scripts I’ve used the FluentShellUnit project and have my test cases as
[TestClass]
[DeploymentItem(@"Modules\SharePoint.psm1", "Modules")]
public class SharePointTests
{
    [TestMethod]
    [TestCategory("SharePointDSCAdministration Module")]
    public voidGetSharePointVersion_should_return_versionnumber_based_on_sharepointinstallation_status()
    {
        varactual = PsFactory.Create(HostState.Core)
            .Load(@"Modules\SharePoint.psm1")
            .Execute("Get-SharePointVersion")
            .FirstResultItemAs();
        Assert.IsTrue(actual == 0 || actual == 14 || actual ==15);
    }
} ...(Read whole news on source site)

PowerShell - Read, Write and Access Registry

AddThis Social Bookmark Button

The registry provider made it easy to work with the registry on a local machine or a remote server to load the registry as a PSDrive and work on it. By default, the Registry provider creates two registry drives HKCU and HKLM. If you want to load other drives, you need to use the New-PSDrive cmdlet to achieve this. This simplifies accessing data in the registry using PowerShell, you can now access the registry as if it were a file system and use the same cmdlets as working with files and directories like Get-Item, Set-Item etc.
We'll make use of
this feature to add/ retrieve values from the registry. I've created some functions to check whether a value exists, get the value and set a value in a registry path, name combination.

FunctionTest-RegistryValue
{
    [CmdletBinding()]
    param
      (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [String]$Path,
       
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [String]$Name
    )
    if(Test-Path $Path)
    {
        $key= Get-Item -LiteralPath $Path

Java vs C# – Part 1

AddThis Social Bookmark Button
Disclaimer: long post!IntroductionWhile some of my friends and colleagues seem to think that I don’t like Java and that I am some sort of Microsoft/.NET zealot, that is actually not true! I do like Java, and I worked with it for several years.There are several articles out there on the differences and similarities between C# and Java, but none actually satisfied me. In this new series of posts, I will try to explain these similarities and differences, as extensively and accurately as I can. I don’t want to start a religious war, but I won’t refrain
from emitting judgments on what I think is best in each. I will try to cover as much as I can, but I won’t drill into APIs, instead will focus on each language’s intrinsic characteristics.This first post will focus on high-level constructs, what I call structure: namespaces and types. I will be covering Java 8 and C# 4, the latest (as of February 2015) versions of these languages.SimilaritiesBoth languages (Java and C#) are case-sensitive, strictly object oriented, offering classes, enumerations and interfaces, single inheritance model and all of the types live in namespaces/packages. Also, all support attributes/annotations, methods...(Read whole news on source site)

Home