".NET" entries

Building C# objects dynamically

Using ExpandoObject to create objects that you can add properties, methods, and events to.

Buy “C# 6.0 Cookbook” in early release.
Editor’s note: This is an excerpt from “C# 6.0 Cookbook,” by Jay Hilyard and Stephen Teilhet. It offers more than 150 code recipes to common and not-so-common problems that C# programmers face every day. In it, you’ll find recipes on asynchronous methods, dynamic objects, enhanced error handling, the Rosyln compiler, and more.

Problem

You want to be able to build up an object to work with on the fly at runtime.

Solution

Use ExpandoObject to create an object that you can add properties, methods, and events to and be able to data bind to in a user interface.

We can use ExpandoObject to create an initial object to hold the Name and current Country of a person.

dynamic expando = new ExpandoObject();
expando.Name = "Brian";
expando.Country = "USA";

Once we have added properties directly, we can also add properties to our object in a more dynamic fashion using the AddProperty method we have provided for you. One example of why you might do this is to add properties to your object from another source of data. We will add the Language property.

Read more…

.NET open source

Microsoft .Net Team Program Manager, Beth Massi, on the open source .NET Core.

wire mesh

You might have heard the news that .NET is open source. In this post I’m going to explain what exactly we open sourced, why we did it, and how you can get involved.

Defining .NET

If you’re not familiar with .NET, it’s a managed execution environment that provides a variety of services to its running applications including things like automatic memory management, type safety, native interop, and multiple modern programming languages that make it easier to build all kinds of apps, for nearly any device, quickly. The first version of .NET was initially released in 2002 and quickly picked up steam in many businesses. Today there are over 1.8 billion active installs of the .NET Framework and 6 million .NET developers in the world.

The .NET Framework consists of these major components: the common language runtime (CLR), which is the execution engine that handles running applications; the .NET Framework Base Class Libraries (BCL), which provides a library of tested, reusable code that developers can call from their own applications; and the managed languages and compilers for C#, F#, and Visual Basic. Application models extend the common libraries of the .NET Framework to provide additional libraries that developers can use to build specific types of applications, like web, desktop, mobile device apps, etc. For more information on all the components in .NET 2015 see: Understanding .NET 2015.

There are multiple implementations of .NET, some from Microsoft and others from other companies or open source projects. In this post, I’ll focus on .NET Core from Microsoft.

Read more…

PowerShell Command Line Introduction

Effectively control Windows from the console

Here’s a slick PowerShell 3.0 one-liner. If you want to pull down an RSS feed from a blog, displaying only the title and publication date try:

Invoke-RestMethod "http://www.dougfinke.com/blog/index.php/feed/" | Select title, pubdate

powershell-0

It’s that simple. No looping, no checking end of stream, no XSLT to handle transforming the XML from the RSS feed, but wait, there’s more. This array of objects is now connected to the entire PowerShell ecosystem. PowerShell is based on .NET so you can use ADO.NET to insert it into a database, use Invoke-RestMethod again and post it to another REST endpoint or spin up Microsoft Excel and control it via its COM API. And that my friends, is the two foot dive into the PowerShell ocean.

PowerShell is Microsoft’s task automation framework, consisting of a command-line shell, an integrated scripting environment (ISE), a scripting language built on .NET Framework, an API allowing you to host PowerShell in your .NET applications, and it is a distributed automation platform. This means if you have PowerShell running on another box, you can remotely execute PowerShell there, if you have the credentials.

Getting started

What you need to do is launch the PowerShell console. On my Windows 8 box I press the Windows button, type “powers“, and hit enter.

powershell-1

Great! I’ve got a blank blue screen. Now what?
Read more…

Developing cross-platform mobile apps with C#

Greg Shackles on using C# and .NET to build apps that work across mobile platforms.

Web developer and author Greg Shackles reveals the advantages of using C# over C++ for writing mobile apps. He also explains why Android and iOS developers should give C# a serious look.

Developer Week in Review: Google I/O's ticket window opens and shuts in record time

Google I/O reg disappoints many, Microsoft shares, and happy birthday to gcc.

Google I/O registration was there and gone so fast you might have missed it if you blinked, Microsoft is sharing more of its code Apache-style, and the leading compiler package in the world celebrates a milestone.

Developer Week in Review: Google I/O’s ticket window opens and shuts in record time

Google I/O reg disappoints many, Microsoft shares, and happy birthday to gcc.

Google I/O registration was there and gone so fast you might have missed it if you blinked, Microsoft is sharing more of its code Apache-style, and the leading compiler package in the world celebrates a milestone.

Developer Week in Review: Are .NET programmers going extinct?

Microsoft embraces HTML5, selling a startup at 15, and a new version of Java looms.

For Microsoft programmers, the week brought fear, uncertainty and doubt regarding their future as an elite class of developers. For a lucky teen, it brought a big paycheck. And for fans of Java, it brought a new version of the popular language one step closer to release.