views:

368

answers:

1

I'm following the tutorial here.

I created a new Web Application. I then added two Class Library projects, Common and Domain. The common project contains the SubSonic library while the Domain project contains the SubSonic .tt and .ttinclude files.

After modifying the settings in Settings.ttinclude, I try to 'Run custom tool' on the tt files and I get this error:

Running transformation: System.ArgumentNullException: Value cannot be null. 
Parameter name: The project does not contain App.config or Web.config file.

I can provide the rest of the stack trace, but it appears that it can't find my Web.config which was the connection string. Adding an app.config to the Domain project just causes the generation step to complain about not finding expected sections.

Is there a way to have these files in a separate assembly but still use the web.config for settings?

+2  A: 

You need to place an App.config in the project you want to generate from. Yes, it's redundant but there's no other way to handle this with T4

Rob Conery
Adding a blank app.config just changes the error to: Running transformation: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.Which I assume is because there is no configuration in the app.config. Is it required that I have the connection string in the app.config? That's seems a bit sucky since I have to have it in the web.config as well for ASP.NET membership.
Jarret R
Adding a connection string does seem to solve it. I don't suppose there is a way to have it pull from the web.config itself? Just as a side note, if you run it against a blank DB (no tables) you get a file that doesn't compile :).Thanks for the help!
Jarret R
You can edit your VS project file to copy the web.config file from the common project to the domain project. That way you're not really maintaining two files.
ranomore