Global code is not allowed in the pure unit

Discussion about the open-source Phalanger [?] project.

Global code is not allowed in the pure unit

Postby eydelber@codeplex » July 30th, 2006, 12:23 am

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
eydelber@codeplex
 
Posts: 5
Joined: January 7th, 2012, 8:57 pm

RE: Global code is not allowed in the pure unit

Postby Lada Prosek » July 30th, 2006, 4:20 pm

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!
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: Global code is not allowed in the pure unit

Postby Lada Prosek » July 30th, 2006, 5:05 pm

No need to add it when it's already there :)
CompilerParameters.CompilerOptions = "/pure-" will do the trick.
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 14 guests

cron

User Control Panel

Login

Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 14 guests