T4 – A namespace cannot directly contain members such as fields or methods
If you are using T4 and get this error you are probably having an error in the template which makes it fail transforming. Check here for a tidbit more information.
An error example:
Error 11 A namespace cannot directly contain members such as fields or methods C:\MyProject\MyOutputFile.cs 1 1 MyProjectName