A new expression requires () or [] after type c# -
i'm using codedom compile following code , save exe
using system; using system.windows.forms; using microsoft.win32.taskscheduler; class program { static void main(string[] args) { using (taskservice ts = new taskservice()) { taskdefinition td = ts.newtask(); td.registrationinfo.description = "does something"; // create trigger fire task @ time every other day td.triggers.add(new dailytrigger { daysinterval = 1 }); // create action launch notepad whenever trigger fires td.actions.add(new execaction("notepad.exe", "c:\\test.log", null)); // register task in root folder ts.rootfolder.registertaskdefinition(@"test", td); // remove task created ts.rootfolder.deletetask("test"); } } }
the problem when select save location , compile errro "a new expression requires () or [] after type". can't see i'm missing here, appreciated.
codedom uses c#2 compiler default, example not compile. compile c# 3 compiler can pass option provider on construction:
var csc = new csharpcodeprovider(new dictionary<string, string>() { { "compilerversion", "v3.5" } });
Comments
Post a Comment