Ice for .NET

The comprehensive features of the Ice platform are available to .NET developers using Ice for .NET. A native C# implementation of Ice provides compatibility with Visual C# as well as Mono, while the Common Language Runtime enables seamless support for other .NET languages such as Visual Basic.

On the strength of Microsoft's product support, .NET has quickly grown to prominence as an effective platform for developing Windows applications and Web services. As a result, Ice for .NET is an excellent platform for integrating Ice services with enterprise technologies such as ASP.NET and SOAP.

Productivity

Due to its additional type safety and garbage collection, C#'s reduced development and testing effort (compared to C++) results in shorter time to market.

The C# language mapping is simple and intuitive and can easily be learned in a few hours. The mapping uses many classes provide by the .NET Framework (including generic containers), so programmers are already familiar with many of the data types, further reducing the learning curve. The Ice run time is fully thread-safe, so developers can develop multi-threaded applications without having to be concerned about maintaining thread-safety for Ice run-time data structures.

Performance

Ice for .NET has been extensively tuned for performance and scalability, so Ice for .NET can be used to create industrial-strength server applications. Using IceBox, several servers can share a single virtual machine, thereby reducing run-time memory footprint.

Portability

Because Ice for C# is written entirely in C#, it can take full advantage of C#'s portability: an Ice for .NET application can run as fully-managed code. In addition, the Ice run time can be used from other .NET languages, such as Visual Basic, so you retain the freedom of using different .NET languages for your development. Support for the .NET Compact Framework means your Ice for .NET applications can run on embedded and mobile devices. Finally, using Ice for Silverlight, you can also run Ice applications directly inside a browser.

Sample Code

To illustrate how Ice is used with C#, consider the following Slice interface definitions:

module Biz {
    struct Item {
        string sku;
        int qty;
    };
    sequence<Item> ItemSeq;
     
    interface Invoice {
        void addItems(ItemSeq items);
        void submit();
    };
    interface InvoiceFactory {
        Invoice* create();
    };
};

C#

C# code that creates an invoice using the factory is shown below:

// Create a proxy for the invoice factory object.
Ice.ObjectPrx proxy = communicator.stringToProxy("InvoiceFactory:tcp -p 9000");

// Narrow the proxy to the proper type.
Biz.InvoiceFactoryPrx factory = Biz.InvoiceFactoryPrxHelper.checkedCast(proxy);

// Use the factory to obtain a proxy for a new invoice object.
Biz.InvoicePrx invoice = factory.create();

// Add items to the invoice.
Biz.Item[] items = new Biz.Item[1];
items[0].sku = "10-6139";
items[0].qty = 3;
invoice.addItems(items);

// Submit the invoice.
invoice.submit();

Visual Basic

Here is the equivalent code in Visual Basic:

' Create a proxy for the invoice factory object.
Dim proxy As Ice.ObjectPrx = communicator.stringToProxy("InvoiceFactory:tcp -p 9000")
' Narrow the proxy to the proper type.
Dim factory As Biz.InvoiceFactoryPrx = Biz.InvoiceFactoryPrxHelper.checkedCast(proxy)
' Use the factory to obtain a proxy for a new invoice object.
Dim invoice As Biz.InvoicePrx = factory.create()
' Add items to the invoice.
Dim items() As Biz.Item = New Biz.Item(0) {}
items(0).sku = "10-6139"
items(0).qty = 3
invoice.addItems(items)
' Submit the invoice.
invoice.submit()
Terms of Use | Privacy © 2014 ZeroC, Inc.