熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

詳解.NET中的動態編譯[3]

2013-11-13 10:48:29  來源: .NET編程 

using System;

using SystemCollectionsGeneric;

using SystemLinq;

using SystemText;

using SystemReflection;

 

namespace RemoteAccess

{

    /// <summary>

          /// Interface that can be run over the remote AppDomain boundary

          /// </summary>

          public interface IRemoteInterface

          {

                   object Invoke(string lcMethodobject[] Parameters);

          }

 

          /// <summary>

          /// Factory class to create objects exposing IRemoteInterface

          /// </summary>

          public class RemoteLoaderFactory : MarshalByRefObject

          {

                   private const BindingFlags bfi = BindingFlagsInstance | BindingFlagsPublic | BindingFlagsCreateInstance;

 

                   public RemoteLoaderFactory() {}

 

                   public IRemoteInterface Create( string assemblyFile string typeName object[] constructArgs )

                   {

                             return (IRemoteInterface) ActivatorCreateInstanceFrom(

                                      assemblyFile typeName false bfi null constructArgs

                                      null null null )Unwrap();

                   }

          }       

}

[]  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/14547.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.