Asp – InvalidCastException when trying to generate code via Subsonic with a vb.net web site

asp.netsubsonic3vb.net

I'm trying to use Subsonic 3.0.0.3 with an existing web site created in vb.net. I've added a reference to SubSonic.Core.dll and added the ActiveRecord tt/ttinclude files. I also added a contextmenu entry to run the t4 templates using instructions I found here.

Whenever I try to run any of the tt files, I receive the following exception. Does this have something to do with me using a web site as opposed to a web application?

f:\Documents and Settings\dbollard\Local Settings\Temp\SQLServer.ttinclude(85,15) : warning CS0219: Compiling transformation: The variable 'parameters' is assigned but its value is never used
ActiveRecord.tt(0,0) : error : Running transformation: System.InvalidCastException: Unable to cast object of type 'Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost' to type 'System.IServiceProvider'.
   at Microsoft.VisualStudio.TextTemplating0b65ddb399f24da48b32cd0d1253af37.GeneratedTextTransformation.GetCurrentProject() in f:\Documents and Settings\dbollard\Local Settings\Temp\Settings.ttinclude:line 103
   at Microsoft.VisualStudio.TextTemplating0b65ddb399f24da48b32cd0d1253af37.GeneratedTextTransformation.GetConnectionString(String connectionStringName) in f:\Documents and Settings\dbollard\Local Settings\Temp\Settings.ttinclude:line 51
   at Microsoft.VisualStudio.TextTemplating0b65ddb399f24da48b32cd0d1253af37.GeneratedTextTransformation.get_ConnectionString() in f:\Documents and Settings\dbollard\Local Settings\Temp\Settings.ttinclude:line 87
   at Microsoft.VisualStudio.TextTemplating0b65ddb399f24da48b32cd0d1253af37.GeneratedTextTransformation.GetReader(String sql) in f:\Documents and Settings\dbollard\Local Settings\Temp\SQLServer.ttinclude:line 5
   at Microsoft.VisualStudio.TextTemplating0b65ddb399f24da48b32cd0d1253af37.GeneratedTextTransformation.LoadTables() in f:\Documents and Settings\dbollard\Local Settings\Temp\SQLServer.ttinclude:line 115
   at Microsoft.VisualStudio.TextTemplating0b65ddb399f24da48b32cd0d1253af37.GeneratedTextTransformation.TransformText() in f:\Documents and Settings\dbollard\Local Settings\Temp\ActiveRecord.tt:line 21

Best Answer

SubSonic can't be used with a web site. The solution was to add a C#.net class library project and reference it from the existing website.

Related Topic