Page 1 of 1

Global code is not allowed in the pure unit

PostPosted: July 30th, 2006, 12:23 am
by eydelber@codeplex
What does this error mean? I am using the PhpCodeDomProvider, and when I call CompileAssemblyFromSource with the code variable as "echo 'hi';", this is the error that I get.

Thanks!
Kevin

RE: Global code is not allowed in the pure unit

PostPosted: July 30th, 2006, 4:20 pm
by Lada Prosek
The CodeDom provider compiles scripts in the "pure" mode, which enforces the program to have the same high-level shape as it's usual on .NET. Only class and function declarations are allowed and exe's entrypoint is a Main method.

This comes out of the fact that people usually use CodeDom to generate something that they are going to consume. Global code is unconsumable from anything else than Phalanger.

However, generating a non-pure exe makes sense. We'll add a way how to do it via CompilerParameters.CompilerOptions. But it will surely default to pure mode, because that's what our most important CodeDom customer (ASP.NET) expects :)

Thanks!

RE: Global code is not allowed in the pure unit

PostPosted: July 30th, 2006, 5:05 pm
by Lada Prosek
No need to add it when it's already there :)
CompilerParameters.CompilerOptions = "/pure-" will do the trick.