就是这样的``小的想实现移动agent,但是苦于现在的一些平台都是java实现的,所以想看.net中可以实现不,讲简单点就是怎么样把一台机子上的代码算法,移动到请求该算法的机器上运行.我已经想过一些办法了,提出来让大家参考,希望大家能给我提供一个比价好的实现方法.谢谢
例如:
1.用WEBSERVICE实现,把类序列化,但是那样只能传递类中的参数,也只是数据在传递而已.
2.把DLL通过STREAM传递,然后在目标主机动态加载方法,但是可操作性差,程序编写麻烦.
3.使用WSC技术,就是把解释性语句通过WS传递,再在目标主机执行解释性代码,但是`````实现起来照样是很复杂的.

解决方案 »

  1.   

    不是算法复杂的问题```而是算法传递的实现````我最想就是通过WS就可以把方法传递过去,.net有实现的方法吗
      

  2.   

    .net 支持动态编译的。下面是一个简单的例子,你可以参考一下:调用 int i = (int)Calc("100+100");,可以得到结果。public  static  object  Calc(string  expression)  
    {  
    string  className  =  "Calc";  
    string  methodName  =  "Run";  
    expression=expression.Replace("/","*1.0/");
                             
    //  创建编译器实例。  
    ICodeCompiler  complier  =  (new  CSharpCodeProvider().CreateCompiler());  
    //  设置编译参数。  
    CompilerParameters  paras  =  new  CompilerParameters();  
    paras.GenerateExecutable  =  false;  
    paras.GenerateInMemory  =  true;  
     
    //  创建动态代码。  
    StringBuilder  classSource  =  new  StringBuilder();    
    classSource.Append("public  class  "+  className  +"\n");  
    classSource.Append("{\n");  
    classSource.Append("        public  object  "  +  methodName  +  "()\n");  
    classSource.Append("        {\n");  
    classSource.Append("                return  "+  expression  +  ";\n");  
    classSource.Append("        }\n");  
    classSource.Append("}");  
     
    //System.Diagnostics.Debug.WriteLine(classSource.ToString());  
     
    //  编译代码。  
    CompilerResults  result  =  complier.CompileAssemblyFromSource(paras,  classSource.ToString());  
                             
    //  获取编译后的程序集。  
    Assembly  assembly  =  result.CompiledAssembly;  
       
    //  动态调用方法。  
    object  eval  =  assembly.CreateInstance(className);  
    MethodInfo  method  =  eval.GetType().GetMethod(methodName);  
    object reobj = method.Invoke(eval,  null);  
    GC.Collect();
    return reobj; }
      

  3.   

    用WEBSERVICE实现,在逐步细化。