How to Use a .NET Assembly

Submit New Article

November 24, 2008 8:00 PM PST



Challenge

Use a .NET assembly. The following code shows a test application that exercises the CakeInfo assembly that was created in the separate item, "How to Create & Version a .NET Assembly." It is similar to the caketester application created in the item, "How to Use and Locate a UNIX (including Linux) Shared Library."

using System
using CakeUtils
namespace SizeCake
public class SizeTest

public static void Main(string [] args)

short numEaters
numEaters = CakeInfo.FeedsHowMany(10, CakeShape.Hexagonal
CakeFilling.Sponge)
Console.WriteLine("This cake will feed " + numEaters + " people "

      

 


Solution

Compile the application using the following command:

csc /r:CakeInfo.dll SizeCake.cs

 

The parameter to the command specifies that the program references the assembly. When the program runs, the output should be:

\\This cake will feed 8 people

 

This item is part of a larger body of items that contrast the ways in which versioning and dynamic linking are handled by Windows* and the .NET Common Language Runtime* (CLR), as opposed to by UNIX-based operating systems such as Linux* or Solaris.*


Source

Versioning, Libraries, and Assemblies