右击"引用",点"添加",再浏览选择你的DLL;在程序中using即可;

解决方案 »

  1.   

    Pls refer to my sample. This is a working sample from one of my project. Have fun.Note: 
    1) IBizLogic is an interface I created.
    2) AssemblyPath is the asimbly I'm going to load, it implements IBizLogic interface.
    Private _BizLogic As IBizLogic
    Private _ObjType As Type = NothingProtected Function LoadBizLogicAssembly(ByVal AssemblyPath As String) As Boolean
            Dim ass As System.Reflection.Assembly = Nothing        Try
                ass = System.Reflection.Assembly.LoadFrom(AssemblyPath)
                Dim AllTypes() As Type = ass.GetTypes()
                If Not ass Is Nothing Then
                    _ObjType = ass.GetType(AllTypes(0).FullName)
                    If Not _ObjType Is Nothing Then
                        _BizLogic = CType(Activator.CreateInstance(_ObjType), IBizLogic)
                        Return True
                    End If
                End If
                Return False
            Catch ex As Exception
                myEventLog.WriteLog(ex)
                Return False
            End Try
        End Function
      

  2.   

    http://www.csdn.net/develop/read_article.asp?id=19286
      

  3.   

    SharpDevelop的例子里边有.好象是project 7/8/9.
    这在C#中非常简单.
      

  4.   

    //MyLib.cs>>>MyLib.dll
    using System;namespace MyLib
    {
    public class MyMathClass
    {
    public static bool IsEven(int n)
    {
    return((n%2)==0);
    }
    }
    }
      

  5.   

    //UsingMyLib.cs调用MyLib.dll和其方法
    using System; 
    using MyLib;class UseMyLib

       public static void Main() 
       { 
          int n = 33;
                
          bool bIsEven = MyMathClass.IsEven(n);
          
          if(bIsEven) Console.WriteLine("{0} is an even number", n);
          else Console.WriteLine("{0} is an odd number", n);
       }
    }
      

  6.   

    我现在就是把几个业务封装在几个dll中,根据用户的不同权限,调用相应的dll,用程序实现,不知道怎么做,反射可以做吗?
      

  7.   

    我现在是这样的作的,有一个dll专门来判断用户权限的,再在调用每个dll时判断其权限,就是调用哪个判断用户权限的dll。
      

  8.   

    // LoadInvoke loads MyAssembly.dll and invokes the MyMethod1 method. 
    // After compiling this class, run LoadInvoke.exe with MyAssembly.dll 
    // as the command line argument, as shown below:
    // LoadInvoke Myassembly.dllusing System;
    using System.Reflection;
    public class LoadInvoke
    {
        public static void Main(string[] args)
        {
            Assembly a = Assembly.LoadFrom(args[0]);
            Type[] mytypes = a.GetTypes();
            BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public | 
                BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);        foreach(Type t in mytypes)
            {
                MethodInfo[] mi = t.GetMethods(flags);
                Object obj = Activator.CreateInstance(t);            foreach(MethodInfo m in mi)
                {
                    m.Invoke(obj, null);
                }
            }
        }
    }
    [C++] 
    // LoadInvoke loads MyAssembly.dll and invokes the MyMethod1 method.
    // After compiling this class, run LoadInvoke.exe with MyAssembly.dll
    // as the command line argument, as shown below:
    // LoadInvoke Myassembly.dll#using <mscorlib.dll>using namespace System;
    using namespace System::Reflection;int main() {
       String* args[] = Environment::GetCommandLineArgs();
       Assembly*  a = Assembly::LoadFrom(args[0]);
       Type*  mytypes[] = a->GetTypes();
       BindingFlags flags = static_cast<BindingFlags>(BindingFlags::NonPublic | BindingFlags::Public |
          BindingFlags::Static | BindingFlags::Instance | BindingFlags::DeclaredOnly);   System::Collections::IEnumerator* myEnum = mytypes->GetEnumerator();
       while (myEnum->MoveNext()) {
          Type* t = __try_cast<Type*>(myEnum->Current);      MethodInfo*  mi[] = t->GetMethods(flags);
          Object*  obj = Activator::CreateInstance(t);      System::Collections::IEnumerator* myEnum = mi->GetEnumerator();
          while (myEnum->MoveNext()) {
             MethodInfo* m = __try_cast<MethodInfo*>(myEnum->Current);
             m->Invoke(obj, 0);
          }
       }
    }
    [Visual Basic] 
    ' Use this class with the LoadInvoke program.
    ' Compile this class using vbc /t:library MyAssembly.vb
    ' to obtain MyAssembly.dll.
    Imports System
    Imports Microsoft.VisualBasicPublic Class MyAssembly
        Public Sub MyMethod1()
            Console.WriteLine("Invoking MyAssembly.MyMethod1")
        End Sub 'MyMethod1
    End Class 'MyAssembly
    [C#] 
    // Use this class with the LoadInvoke program.
    // Compile this class using csc /t:library MyAssembly.cs
    // to obtain MyAssembly.dll.
    using System;public class MyAssembly
    {
        public void MyMethod1()
        {
            Console.WriteLine("Invoking MyAssembly.MyMethod1");
        }    
    }