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

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

2022-06-13   來源: .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-2022 電腦知識網 Computer Knowledge   All rights reserved.