Unable to do compilation using CodeDom in ASP.NET

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
 
B

Bruce Barker

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)
 
J

jimjxr

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.
 
Joined
Oct 17, 2006
Messages
1
Reaction score
0
It can be solved by Setting the full path for the output assembly

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top