And an assembly module package

1. What is the module package

The most direct form of module package is a library, but the library is not the only form of module package, we will achieve certain functions in the form of code libraries packaged together, we can achieve the purpose of the module package, we have to design a calculator for example:

CalDll is calculated to achieve the library

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CalDll
{
    public class Calculator
    {
        public int Add(int a, int b)
        {
            return a + b;
        }
        public double Add(double a, double b)
        {
            return a + b;
        }
    }
}

 

In winform form, we call the library to achieve calculated to achieve the purposes of the calculation:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CalDll;

namespace CalDemo
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void btnCal_Click(object sender, EventArgs e)
        {
            int num1 = Convert.ToInt32(this.txtNum1.Text.Trim());
            int num2 = Convert.ToInt32(this.txtNum2.Text.Trim());

            int result = new Calculator().Add(num1, num2);
            this.lblResult.Text = result.ToString();
        }
    }
}

 

Program results are as follows:

 

II. What is the program set

Assembly unit of deployment is an application, .NET application includes one or more assemblies. Usually extension is .NET executable EXE or DLL called assembly. Never understood as a simple assembly Dll file, this idea is wrong.

Logical architecture of the figure shows the assembly of:

Information about the assembly can be modified in the Properties in AssemblyInfo.CS in:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// about an assembly by the following general information
 // control feature set. Change these attribute values to modify
 // information associated with the assembly. 
[Assembly: AssemblyTitle ( " CalDemo " )]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright @ ")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The ComVisible set to false so that this assembly type
 // not visible to COM components. If access type in this assembly from the COM,
 // the ComVisible attribute on the type is set to true. 
[Assembly: the ComVisible ( to false )]

// If this project is exposed to COM, following GUID is for the type of library ID 
[Assembly: the Guid ( " b9d17b02-0550-4197-b5d5-92d40c4d4254 " )]

// Version information for an assembly consists of the following four values: 
 // 
//       Major Version
 //       Minor Version 
 //       generate numbers
 //       Revision Number
 // 
// You can specify all these values, you can also use the "generate numbers" and "revision number" default value
 // is used as shown below, "*": 
 // [Assembly: the AssemblyVersion ( "1.0 *.")] 
[Assembly: the AssemblyVersion ( " 1.0.0.0 " )]
[assembly: AssemblyFileVersion("1.0.0.0")]

 

Guess you like

Origin www.cnblogs.com/Artist007/p/11014264.html