【发布时间】:2014-09-18 12:32:11
【问题描述】:
我正在尝试在运行时创建一个 DLL 文件,事实上我需要将编码数据保存到DLL。我的代码是这样的:
class DllFile
{
public static void CreateDllFile(string source)
{
source = @"using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LicensecodeDll
{
class Check
{
public string returnValue()
{
return " + source + ";" + "}}}";
var provider = new CSharpCodeProvider();
var options = new CompilerParameters
{
OutputAssembly = "test.dll"
};
var results = provider.CompileAssemblyFromSource(options, new[] { source });
}
}
}
一切正常,我的 ddl 已创建,但我需要读取保存在 dll 文件中的值,我的意思是我需要 returnValue。我该怎么做?
最好的问候。任何想法将不胜感激。
【问题讨论】:
-
加载程序集并使用反射?
-
哇,我该怎么做?!!!!!!
-
反射是您可以询问对象的地方,例如获取属性和方法。调用没有对已构建程序集的引用的东西的唯一方法。
标签: c# dll .net-assembly