I am trying to access a custom section in the app.config file from the t4 template in VS2010, but the assembly that defines the user section cannot be loaded.
I use ConfigurationAccessor to get the section (ref http://skysanders.net/subtext/archive/2010/01/23/accessing-app.configweb.config-from-t4-template.aspx ).
app.config:
<configSections>
<section name="MyProviders" type="System.Web.Security.MySection, MyAssembly" />
</configSections>
<MyProviders default="SQLMyProvider">
<providers>
<add name="SQLMyProvider" ... connectionStringName="MyConnectionString" />
</providers>
</MyProviders>
Call this line in a .tt file:
MySection section = (MySection)config.Configuration.GetSection("MyProviders");
Gives this error:
Conversion start: System.Configuration.ConfigurationErrorsException: An error occurred while creating the configuration section handler for MyProviders: Failed to load file or assembly "MyAssembly" or one of its dependencies. The system cannot find the specified file.
.tt , , .
MySection tt, app.config.
?