I get this error only while running code under VS.net (2012 and 2015): either ReSharper driven unit testing, running my program with attached debugger, or even when Starting Without Debugging. Tests run fine on the build server and when running the program on its own. It used to work until recently. I am doing this:
Dictionary<string, string> providerOptions = new Dictionary<string, string>
{
{"CompilerVersion", "v4.0"}
};
CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);
CompilerParameters compilerParams = new CompilerParameters
{
GenerateInMemory = true,
GenerateExecutable = false
};
CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, source);
And this is the trace:
System.ComponentModel.Win32Exception (0x80004005): A required privilege is not held by the client
at Microsoft.Win32.NativeMethods.CreateDirectory(String path, SafeLocalMemHandle acl) at System.CodeDom.Compiler.TempFileCollection.CreateTempDirectoryWithAce(String directory, String identity) at System.CodeDom.Compiler.TempFileCollection.GetTempFileName(String tempDir) at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated() at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile) at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources) at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
Does that look familiar to anyone? I tried to generate my code with writing to a file with same issue.