Unable to do compilation using CodeDom in ASP.NET

  • Thread starter Thread starter jimjxr
  • Start date Start date
J

jimjxr

Hi,

I'm trying to use ICodeCompiler.CompileAssemblyFromSource to compile C#
source code (in a string) into assembly dynamically. This works fine in
a console program, but fails under ASP.NET, the compilation error I got
is CS1619: "Cannot create temporary file
'c:\WINDOWS\system32\CSC201E.tmp' -- Access is denied. "

It seems that the C# compiler tries to create some temp file in my
system32 dir, and ASP.NET's process doesn't have the permission to do
so. So how do I tell C# compiler to use a proper place for temp file? I
tried to set CompilerParameters.TempFiles, but it doesn't work.

Thanks

Jim
 
the vb.net and c# compilers unlike the javascript.net compiler, can not
compile from a string. the compile from string method writes the string to
disk before calling the compiler. it uses the
CompilerParameters.TempFiles.TempDir to get the temp folder.

-- bruce (sqlwork.com)
 
Thanks for the insight, but I don't think this is the case. I have set
compilerParams.TempFiles = new TempFileCollection(Path.GetTempPath()),
but this still doesn't resolve the error.

I even tried to create a temp file for the source code and use
CompileAssemblyFromFile, this doesn't work either.
 
It can be solved by setting the full path for the property

OutputAssembly = @"C:\PIANX.dll";

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top