Reputation: 7301
I am trying to create a DLL file in runtime ,as a matter of fact i need to save an encoded data to DLL
.My code is like this :
class DllFile
{
public static void CreateDllFile(string source)
{
var provider = new CSharpCodeProvider();
var options = new CompilerParameters
{
OutputAssembly = "test.dll"
};
var results = provider.CompileAssemblyFromSource(options, new[] { source });
}
}
I expect from this code to create a dll file but it doesn't create
The error is :The pointer for this method was null
Best regards.Any ideas will be appreciated.
Upvotes: 1
Views: 223
Reputation: 1198
Any errors would be in the Errors property of the CompilerResults returned from the CompileAssemblyFromSource method. Have you tried printing them out to see if there are errors ?
CompilerResults results = provider.CompileAssemblyFromSource(options, new[] { source });
foreach(CompilerError error in results.Errors)
{
Console.WriteLine(error.ToString());
}
Upvotes: 1
Reputation: 1063198
Compilation errors are reported via the returned value:
var results = provider.CompileAssemblyFromSource(options, new[] { source });
Now check results
, and in particular results.Errors
.
You can also check results.NativeCompilerReturnValue
- that should be 0
for success, and non-zero for failure.
Upvotes: 2