C# 从源代码+;混淆=don';行不通
我已经从源代码开始编译了。但当我使用诸如RedGate SmartAssembly或Themida之类的代码保护器时,它会停止工作,并出现错误“无法加载文件或程序集或其依赖项”。你能帮我吗C# 从源代码+;混淆=don';行不通,c#,obfuscation,compileassemblyfromsource,C#,Obfuscation,Compileassemblyfromsource,我已经从源代码开始编译了。但当我使用诸如RedGate SmartAssembly或Themida之类的代码保护器时,它会停止工作,并出现错误“无法加载文件或程序集或其依赖项”。你能帮我吗 using System; using System.CodeDom.Compiler; using System.Reflection; using Microsoft.CSharp; namespace stringToCode { public class Program {
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.CSharp;
namespace stringToCode
{
public class Program
{
public static int q = 0;
static void Main(string[] args)
{
try
{
string source = "namespace stringToCode { public class FooClass { public void Execute() { Program.q = 1; } } }";
Console.WriteLine("q=" + q);
using (var foo = new CSharpCodeProvider())
{
var parameters = new CompilerParameters();
parameters.GenerateInMemory = true;
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
try
{
string location = assembly.Location;
if (!String.IsNullOrEmpty(location))
{
parameters.ReferencedAssemblies.Add(location);
}
}
catch (NotSupportedException)
{ }
}
var res = foo.CompileAssemblyFromSource(parameters, source);
var type = res.CompiledAssembly.GetType("stringToCode.FooClass");
var obj = Activator.CreateInstance(type);
var output = type.GetMethod("Execute").Invoke(obj, new object[] { });
Console.WriteLine("q=" + q);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);;
}
Console.ReadLine();
}
}
}
对不起,我的问题。我只是明白为什么会这样) 这是一个示例代码。我从服务器获取的代码存在的主要问题。
因此,当我混淆我的变量时,我不会在我与CompileAsemblyFromSource一起使用的“在线”代码中混淆它们。所以这是行不通的。因为变量没有相同的名称。对不起我的问题。我只是明白为什么会这样) 这是一个示例代码。我从服务器获取的代码存在的主要问题。 因此,当我混淆我的变量时,我不会在我与CompileAsemblyFromSource一起使用的“在线”代码中混淆它们。所以这是行不通的。因为变量没有相同的名称