316 ❘
CHAPTER 15 Using ironPython from other .net LangUages
CoNSIdERINg THE dyNAmIC TyPE IN C# 4.0 Visual Basic.NET has always had a kind of dynamic lookup in the form of late bind-
ing. However, C# has always used early binding. That has changed with C# 4.0 with
the new dynamic lookup functionality found in the DLR. Dynamic lookup provides
you with these additional capabilities when working with C#:
➤
A shared infrastructure for runtime name resolution across all .NET languages.
➤
➤
➤
Enhanced support for the Office Primary Interoperability Assemblies (PIA) and
Component Object Model (COM) interoperability that negates the need to use
bulky type libraries and optional arguments in function calls.
➤
➤
The ability to consume dynamic languages by making it possible to interact
with dynamic language types.
➤
➤
Improved reflection support, which makes it possible to easily instantiate
classes and call arbitrary methods that are not known at compile time.
The
dynamic
type has considerably more to offer than a sidebar can hold. For
more information check out the article at
http://msdn.microsoft.com/library/
dd264736(VS.100).aspx
. This article provides a good example of how the
dynamic
keyword comes into play.
Working with the App.CoNFIg File In some cases, you might want to configure your application using an
App.CONFIG
file. Using the
App.CONFIG
file tends to ensure that your application works better between development machines.
In addition, using the
App.CONFIG
file can make it easier to work with DLR using older versions of
Visual Studio. Most important of all, using the
App.CONFIG
file ensures that anyone working with
the application uses the correct version of the DLLs so that any DLL differences aren’t a problem.
Your project won’t contain an
App.CONFIG
file at the outset. To add this file, right-click the project
entry in Solution Explorer and choose Add
➤➤➪➤➤
New Item from the context menu. You see the Add
New Item dialog box shown in Figure 15-5. Highlight the Application Configuration File entry as
shown and click Add. Visual Studio automatically opens the file for you.
The
App.CONFIG
file contains entries that describe the Microsoft scripting configuration. In most
cases, you begin by defining a
element, which describes a
element. The
element contains a list of languages you want to use in a
element, as shown in Listing 15-4.