易采站长站为您分析C#执行js动态编译的方法,是涉及动态编译脚本非常实用的技巧,需要的朋友可以参考下
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace webpro
{
public class JScripta
{
private static readonly CodeDomProvider _provider = new Microsoft.JScript.JScriptCodeProvider();
private static Type _evaluateType;
private const string scriptStr = @"package fhs
{
public class MyJs
{
public static function test1(paramr1)
{
var retString = paramr1+ '是无敌的!';
return retString;
}
}
}";
public static object JScriptRun(string jsMethodName,object[] testParams)
{
//编译的参数
本文实例讲述了C#执行js动态编译的方法。。具体实现方法如下:
复制代码 using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace webpro
{
public class JScripta
{
private static readonly CodeDomProvider _provider = new Microsoft.JScript.JScriptCodeProvider();
private static Type _evaluateType;
private const string scriptStr = @"package fhs
{
public class MyJs
{
public static function test1(paramr1)
{
var retString = paramr1+ '是无敌的!';
return retString;
}
}
}";
public static object JScriptRun(string jsMethodName,object[] testParams)
{
//编译的参数










