Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Access Denied error received while compiling code using ICodeCompiler.CompileAsseblyFromSource()

$
0
0

I get this strange error that says access denied although there arefull permissions. Stack trace is as mentioned below

System.UnauthorizedAccessException: Access to the path 'C:\Users\PROSIGHT SYSTEM\AppData\Local\Temp\r441q06c.0.js' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters options, String[] sources)
   at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters options, String source)
   at System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSource(CompilerParameters options, String source)
   at ProSight.Portfolios.FunctionEngine.FunctionScriptEngine.psScriptEngine.Test(String sFunction)
   at ProSight.Portfolios.BusinessLogic.Infrastructure.Objects.psFunctionObj.FunctionsScript.refreshFunctionsCache()
   at ProSight.Portfolios.BusinessLogic.Infrastructure.Objects.psFunctionObj.FunctionsScript.readFunctionsCode()
   at ProSight.Portfolios.BusinessLogic.TS.TransactionalScenario.psTSFunctionEngine.getFunctionsScript(Int32 iUserID, psResultContainer oResults)
&lt/Exception&gt

I ran process monitor and found that  the issue is while creation of the file in the temp folder due toDELETE PENDING status. Internally CompileAssembleFromSource, repeatedlycreates and deletes *.js files with the same name over and over again in the temp folder, that too this does not come in the first time, a lot many times the creation and deletion succeeds, and ultimately at some point it throws error due to the DELETE PENDING status while trying to create that .js file again.

Amazingly when I run on a different machine, everything works perfectly.

Is this a bug in Visual C# that it does not retries to create the file or handle this error by renaming the created file rather than throwing up error. In any case I need to know how should I handle this issue.

Is there a way to direct this function not create the file with the same name over and over again, but with a different name.

The issue is occuring on Windows 2008 Server. 

Thanks In advance!!!


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>