创建编译类:
using Microsoft.CSharp;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace H264Player
{
public class ImportDLLCompiler
{
private string _dllPath;
private string className;
private Assembly assembly;
public ImportDLLCompiler(string className,string dllpath="")
{
this.className = className;
_dllPath = dllpath;
assembly = Compile();
}
private Assembly Compile()
{
// 编译器
CodeDomProvider cdp = CodeDomProvider.CreateProvider("C#");
// 编译器的参数
CompilerParameters cp = new CompilerParameters();
cp.ReferencedAssemblies.Add("System.dll");