0

I have a script file(.ccs) with some functions that creates an excel file with data. How can I compile this file within a c# function? I also have to pass some parameters to it.

I can't find any information on the internet about it. This is the path to the file.

string ccsFile = "C:\\Templates\\myCCSFile.ccs";
2
  • 1
    Are you talking about CS-Script? There's information here about it: csscript.net Commented May 21, 2014 at 12:42
  • I can't find anything out about ccs scripts so I can't provide insight into the question as asked. That said, one way to create an excel file with C# is to use the COM automation library. You can find information about that here: support.microsoft.com/kb/302084 Commented May 21, 2014 at 12:45

1 Answer 1

2

For CS script - the comment above will work - for C# you need to take a look at the CSharpCodeProvider - it generally looks like that:

CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();

System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = icc.CompileAssemblyFromSource(parameters,SourceString);

The trick is to have some entry point afterward that you find and then invoke trough reflection.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.