Vincent Leung .NET Tech Clips

The latest tech clips from the .NET community

Managed Extensibility Framework

December 2, 2009 Posted by Vincent Leung | MEF, Silverlight | | No Comments Yet

Running IronPython Scripts from a C# 4.0 Program

 

Running IronPython Scripts from a C# 4.0 Program

Before you read this you may want to check out my other post.

IronPython is a scripting language hosted on the .NET platform. This posts shows how you can use the Dynamic Language Runtime (DLR) and the new C# 4.0 dynamic keyword to call an IronPython script from a C# program.

image

Test.py

import sys

def Simple():
    print "Hello from Python"
    print "Call Dir(): "
    print dir()
    print "Print the Path: "
    print sys.path

 

using System;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

public class dynamic_demo
{
    static void Main()
    {
        var ipy = Python.CreateRuntime();
        dynamic test = ipy.UseFile("Test.py");
        test.Simple();
    }
}

image

Via Charlie Calvert’s Community Blog : Running IronPython Scripts from a C# 4.0 Program

October 27, 2009 Posted by Vincent Leung | .NET 4, Python | | No Comments Yet

Dynamic, Interop, Named & Optional Arguments in C# 4.0

October 25, 2009 Posted by Vincent Leung | .NET 4 | | No Comments Yet

All you need to know about Visual Studio 2010 Beta 2

image

Visual Studio 2010 Beta 2 Download – Home

http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

What’s new in .NET Framework 4

.NET Framework 4 Beta 2 Documentation

http://msdn.microsoft.com/en-us/library/w0×726c2%28VS.100%29.aspx

Walkthroughs

Training Kit – Oct. Preview

http://www.microsoft.com/downloads/details.aspx?FamilyID=752CB725-969B-4732-A383-ED5740F02E93&displaylang=en

Training Course – includes videos and hands-on-labs designed to help you learn how to utilize the Visual Studio 2010 features and a variety of framework technologies

http://channel9.msdn.com/learn/courses/VS2010/

Samples – C#, F#, Parallel Processing, Office, SharePoint

http://msdn.microsoft.com/en-us/dd238515.aspx

Visual Studio 2010 Beta 2 and Silverlight updates – Tim Heuer

http://timheuer.com/blog/archive/2009/10/19/silverlight-and-visual-studio-2010-beta-2.aspx

http://timheuer.com/blog/archive/2009/10/22/can-i-use-vs2010-for-silverlight-3-development.aspx

Silverlight Toolkit Oct. 2009 Release – support Visual Studio 2010 design time experience, Extensible Charting, Drag & Drop support for controls

http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20October%202009%20change%20list&referringTitle=Home

Visual Studio 2010 Beta 2 from an ASP.NET MVC Perspective – Phil Haack

http://haacked.com/archive/2009/10/20/vs10beta2-and-aspnetmvc.aspx

AJAX Control Toolkit

Download Deep Zoom Composer

Download ASP.NET Ajax Control Toolkit

Microsoft Ajax Library and Visual Studio 2010 Beta 2 – Stephen Walther

http://stephenwalther.com/blog/archive/2009/10/21/the-microsoft-ajax-library-and-visual-studio-beta-2.aspx

Visual Studio 2010 and .NET Series by ScottGu

http://weblogs.asp.net/scottgu/archive/2009/08/25/vs-2010-and-net-4-series.aspx

IronPython – http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125

  1. Install IronPython 2.6 CTP for .NET 4.0 Beta 2.msi from -http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125
  2. Follow any of the many dynamic walkthroughs online -http://blogs.msdn.com/vbteam/archive/2008/12/17/walkthrough-dynamic-programming-in-visual-basic-10-0-and-c-4-0-lisa-feigenbaum.aspx

IronRuby

http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125

Issues:

No Javascript Intellisense – http://west-wind.com/weblog/posts/50857.aspx

In case you need to uninstall Visual Studio:

  • Try to uninstall using the ISO image.
  • Or you can try this if you don’t have the ISO.1. Uninstall TFS Object Model (This step is Visual Studio 2010 Team Suite only)
    From Add/Remove, uninstall Microsoft Team Foundation Server 2010 Beta 1 Object Model
    2. Uninstall all instances of Visual Studio 2010 products (for example, Visual Studio 2010 Ultimate).
    3.1 If you have previous versions of Visual Studio
    Uninstall other remaining supporting products, in the specified order. (Ignore items that are not present on your computer.)
    a.    Visual Studio 2010 Tools for Office Runtime Beta 2
    b.    The .NET Framework version 4 Language Pack
    c.    The .NET Framework version 4 Extended (reboot, if prompted)
    d.    The .NET Framework version 4 Client (reboot, if prompted)

    3.2 If no previous versions of Visual Studio
    3.2.1 Optionally, uninstall the following supporting products that may have been installed with Visual Studio 2010.  NOTE: These components may also be used by other product suites on your computer.
    a.    Web Deployment Tool
    b.    Silverlight 3 SDK
    c.    SQL Server 2008 Management Objects
    d.    SQL Server CLR Types
    e.    SQL Server 2008
    f.    SQL Server 2008 Native Client
    g.    SQL Server Compact 3.5 SP2

    3.2.2 Uninstall other remaining supporting products, in the specified order.  (Ignore items that are not present on your computer.)
    a.    Visual Studio 2010 Tools for Office Runtime Beta2
    b.    The .NET Framework version 4 Language Pack
    c.    The .NET Framework version 4 Extended (reboot, if prompted)
    d.    The .NET Framework version 4 Client (reboot, if prompted)
    4. Reboot
    5. Uninstall C++ 2010 Redistributable
    From Add/Remove, uninstall Microsoft Visual C++ 2010 Beta 2 Redistributable (x86 and/or x64)
    6. Reboot

October 23, 2009 Posted by Vincent Leung | .NET 4, VS2010, Visual Studio | | No Comments Yet

What is the difference between a.Equals(b) and a == b?

Value Types:
For value types, “==” and Equals() works same way : Compare two objects by VALUE
Example:
int i = 5;
int k= 5;
i == k > True
i.Equals(k) > True

Reference Types:
For reference types, both works differently :
“==” compares REFERENCE – returns true if and only if both references point to the SAME object.

Equals method compares object by VALUE.

Example:
StringBuilder sb1 = new StringBuilder(”Mahesh”);
StringBuilder sb2 = new StringBuilder(”Mahesh”);
sb1 == sb2 > False
sb1.Equals(sb2) > True

However

String s1 = “zzz”;
String s2 = “zzz”;
In above case the results will be,
s1 == s2 > True
s1.Equals(s2) > True

Why? Does that mean String a Value Type?

No, String IS a Reference Type. Although string is a reference type, the equality operators (== and !=) are defined to compare the values of string objects, not references. This makes testing for string equality more intuitive. For example:

September 28, 2009 Posted by Vincent Leung | .NET, C# | | No Comments Yet

VS 2010 and .NET 4 Series – ScottGu’s Blog

 

image

Scott Gu will update this page with links to the individual posts I do as I publish them along the way:

Via VS 2010 and .NET 4 Series – ScottGu’s Blog

August 30, 2009 Posted by Vincent Leung | .NET 4, VS2010 | | No Comments Yet

Windows 7 API Code Pack for Microsoft® .NET Framework v1.0

image image

The individual features supported in this version (v1.0) of the library are:

  • Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars.
  • Windows 7 Libraries, Known Folders, non-file system containers.
  • Windows Shell Search API support, a hierarchy of Shell Namespace entities, and Drag and Drop functionality for Shell Objects.
  • Explorer Browser Control.
  • Shell property system.
  • Windows Vista and Windows 7 Common File Dialogs, including custom controls.
  • Windows Vista and Windows 7 Task Dialogs.
  • Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs. (DirectWrite and WIC have partial support)
  • Sensor Platform APIs
  • Extended Linguistic Services APIs
  • Power Management APIs
  • Application Restart and Recovery APIs
  • Network List Manager APIs
  • Command Link control and System defined Shell icons.

Samples:
The Code Pack also contains sample applications built using this library. Each sample has a C# version and a VB.NET version and has its own solution file.
Documentation:
The Code Pack also includes API reference documentation. API documentation files can be found in two separate files WindowsAPICodePackHelp and DirectXCodePackHelp in the download section.

Videos:
Two minute videos demonstrating some of the features in this release are now available:

More Videos

Blogs

 

Via Windows 7 API Code Pack for Microsoft® .NET Framework – Home

August 9, 2009 Posted by Vincent Leung | .NET, Windows | | No Comments Yet

Visual Studio 2010 and .NET Framework 4 Training Kit

 

May Preview of the Visual Studio 2010 and .NET Framework 4 Training Kit

Download details: Visual Studio 2010 and .NET Framework 4 Training Kit

May 20, 2009 Posted by Vincent Leung | .NET 4, VS2010 | | No Comments Yet

Fluent DateTime for .NET

 

A set of (Ruby inspired) C# Extension Methods for easier and more natural DateTime handling and operations in .NET.
Allows you to write code like this: Alpha

DateTime.Now + 1.Week() + 3.Days + 14.Minutes();
3.Days().Ago();
5.Days().After(new DateTime(2000, 1, 1));
DateTime.Now.NextDay();
DateTime.Now.WeekAfter();
DateTime.Now.Midnight();
DateTime.Now.SetTime(11, 55, 0);

Fluent DateTime – Home

February 24, 2009 Posted by Vincent Leung | .NET, Libraries | | No Comments Yet

.NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play)

I’ve been working on an application recently that needs to be able to communicate through a router/firewall using TCP. I’ve read/heard a bit of information about NAT Routers and UPnP; the technoligies used in almost every router sold commercially. So, I knew that you could use the Universal Plug and Play (UPnP) features of the NAT Router to automatically open up the firewall via Port Forwarding to allow other computers on the Internet to connect directly to the one your application is running on. One thing I didn’t know what that Windows (since Windows XP) has the NATUPnP 1.0 Type Library (NATUPNP.DLL) COM Component that you can utilize within your applications to do this for you.

image

 

Via .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play)

February 6, 2009 Posted by Vincent Leung | .NET | | No Comments Yet