简体   繁体   中英

CompileAssemblyFromSource returns error “Compiling Expression: cannot open c:\Users\*” for reading 'c:\Users\* is not a valid Win32 resource file

My application generates and compiles code runtime:

CompilerParameters m_cp = new CompilerParameters();
m_cp.ReferencedAssemblies.Add("system.dll");            
m_cp.GenerateExecutable = false;
m_cp.GenerateInMemory = true;
m_cp.CompilerOptions = "/optimize";
...
CompilerResults cr = new CSharpCodeProvider().CompileAssemblyFromSource(m_cp, code.ToString());
if (cr.Errors.HasErrors)
{
   //getting here with error:
   //"Compiling Expression: cannot open c:\Users\*" for reading 
   //'c:\Users\* is not a valid Win32 resource file
   // Example of file c:\Users\[User]\AppData\Local\Temp\1\faw31esr\CSC23CEA88A205E4588B799FD8B4456176B.TMP
}

Issue is happening only for some users but their access is OK (access is the same as for trouble-free users). Eg problematic users can get to shown directory and remove files.

One of vulnerability management products blocked file access and caused error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM