Microsoft KB Archive/323491

= HOW TO: Create and Use a Meta Data Assembly =

Article ID: 323491

Article Last Modified on 4/22/2004

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft .NET Framework 1.1
 * Microsoft .NET Framework 1.0

-



This article was previously published under Q323491



IN THIS TASK
SUMMARY Requirements What Are Meta Data Assemblies? Create a Simple .NET Framework Component Use the Soapsuds Tool to Generate the Meta Data Assembly
 * Alternative Use of -nowrappedproxy

Troubleshooting REFERENCES



SUMMARY
This step-by-step article describes what meta data assemblies are and in what scenarios you can use them. This article also explains how to use the Soapsuds tool with the nowrappedproxy flag to generate a meta data assembly.

back to the top

Requirements
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
 * Visual Studio .NET
 * Microsoft Internet Information Services (IIS)

This article assumes that you are familiar with the following topics:
 * Visual Studio .NET
 * Microsoft .NET Framework
 * Microsoft .NET Remoting

back to the top

What Are Meta Data Assemblies?
Meta data assemblies are .NET Framework assemblies that contain only meta data and type information. Meta data assemblies are similar to type libraries in COM, but meta data assemblies do not contain any implementation code.

Together with a distributed client application, you can deploy meta data assemblies that contain enough information for that client application to create a remote proxy and use that remote proxy to invoke methods on the actual assembly, which may reside on a different computer.

The following guide demonstrates how to generate a meta data assembly from a simple .NET-based component.

back to the top

Create a Simple .NET Framework Component
 In Visual Studio. NET, on the File menu, click New, and then click Project. Under Project Types, click Visual C# Projects. Under Templates, click Class Library. Change the Name to MyRemoteComp, and then click OK.

The class library project is created. Class Class1 in the MyRemoteComp namespace is created in Class1.cs by default.  Copy and paste the following code in Class1: public string SayHello(string sName) {   return &quot;Hi, &quot; + sName; }                    On the Build menu, click Build Solution to build the class library. The assembly is named MyRemoteComp.dll.

back to the top

Use the Soapsuds Tool to Generate the Meta Data Assembly
This section explains how to use the Soapsuds tool (Soapsuds.exe) and it's nowrappedproxy flag to create the meta data assembly. The simple assembly file that you created in the previous steps is used as input:
 * 1) On the Start menu, point to Programs, click Microsoft Visual Studio .NET, click Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt.
 * 2) At the Visual Studio .NET Command Prompt, change to the directory where you created your simple class library assembly. By default, the assembly is in the  \bin\debug directory. Type the command dir, and then note that assembly named MyRemoteComp.dll appears in the file list.
 * 3) Run the Soapsuds tool against your assembly. To do this, type the following command (as one command line) at the Visual Studio .NET Command Prompt:

'''soapsuds.exe -inputassemblyfile:myremotecomp

-outputassemblyfile:myremotecomp.metaonly.dll -nowrappedproxy'''

You now have a second assembly .dll named Myremotecomp.metaonly.dll. This is the meta data assembly.

You can use this meta data assembly in remote client development and deployment. When you develop the remote client, add a reference to this meta data assembly instead of a reference to the assembly that contains the implementation code. If you are developing in Visual Studio .NET, follow these steps to add the reference:
 * 1) On the Project menu, click Add Reference.
 * 2) Click Browse, locate your meta data assembly, and then click Open.

Your assembly appears under Selected Components.
 * 1) Click OK.

You can now reference and use the class in your client code.

back to the top

Alternative Use of -nowrappedproxy
You can use a meta data assembly after your clients are compiled, also. In this scenario, you must generate a meta data assembly file that has the same name as the original input assembly. To do this, run the Soapsuds tool by typing the following command (as one command line) at the Visual Studio .NET Command Prompt:

'''soapsuds.exe -inputassemblyfile:myremotecomp

-outputassemblyfile:metaonly/myremotecomp.dll -nowrappedproxy'''

This command creates the new meta data assembly file in the directory \bin\debug\metaonly, and gives the new meta data assembly file the same name as the input assembly file. It is helpful to give this new file a meaningful name temporarily, while you are manipulating the file before deployment. When you deploy the new meta data assembly, change the name to the original name.

You can deploy this new assembly to remote clients that have already been compiled against the original input assembly. In this deployment configuration, when the client application loads the assembly, the client looks for the original assembly file by name, but the client finds the meta data assembly by the same name. The client requires only the meta data and type information that is contained in the assembly file to invoke the remote methods, so the meta data assembly is enough for this purpose.

back to the top

Troubleshooting

 * When you run the Soapsuds.exe command, verify that you do not include the .dll file name extension when you specify the input assembly file.
 * You can abbreviate the Soapsuds.exe arguments, as described in the Microsoft Developer Network (MSDN) article that is listed in the &quot;References&quot; section.
 * Be careful when you change the name of the output assembly file after it has been generated. As with any .NET Framework assembly, the name of the .dll file is a part of the meta data. An error will occur when the assembly is loaded if the name is different from the name that appears in the meta data.

back to the top

