Thanks Otis,
The error I am getting is not launched while using the generated code, but while generating the code.
Here is the task defined:
<task name="uFACTS.Tasks.Common.Utility.General.MsgDefClassGenerator" assemblyFilename="SD.LLBLGen.Pro.TaskPerformers.dll"
taskPerformerClass="SD.LLBLGen.Pro.TaskPerformers.CodeEmitter" description="Generates the MsgDef static classes" isOptional="true">
<supportedPlatforms/>
<supportedTemplateGroups/>
<dependencies/>
<parameters>
<parameter name="destinationFolder" defaultValue="" isOptional="false" description="The folder to generate the code in"/>
<parameter name="filenameFormat" defaultValue="MsgDefType.[extension]" isOptional="false" description="The destination file format specification"/>
<parameter name="templateID" defaultValue="uFACTS_MsgDefTypeTemplate" isOptional="false" description="The ID of the template to use." valueType="templateID"/>
<parameter name="emitType" defaultValue="generic" isOptional="false" description="The type of code generation to perform." valueType="emitType"/>
<parameter name="templateBindingDefinitionName" defaultValue="" isOptional="true" description="The name of the TemplateBindings from which to pick the templateID specified. Specifying this parameter will always force the templateID to be picked from the templateBindings with the name specified."/>
<parameter name="failWhenExistent" defaultValue="false" isOptional="true" description="Flag to signal what to do when the destination file already exists." valueType="boolean"/>
</parameters>
</task>`
...and here are the content of the templates
MsgDefTypeTemplate
namespace uFACTS.Utility.General
{
<# uFACTS_MsgDefType_GetTypes #>
}
MsgDefType_GetTypes
<[ System.Diagnostics ]>
<%
//Debugger.Break();
Hashtable groups = new Hashtable();
const string ConnectionKeyString = "Main.ConnectionString";
OracleConnection conn = new OracleConnection(SD.LLBLGen.Pro.ORMSupportClasses.ConfigFileHelper.ReadConnectionStringFromConfig(ConnectionKeyString));
conn.Open();
OracleCommand cmd = new OracleCommand("select msg_def_nu, const_na, msg_desc, msg_text from ui_msg_def order by msg_def_nu", conn);
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
string group = string.Empty;
string name = reader["const_na"].ToString();
if (!name.Contains("."))
{
group = "General";
}
else
{
group = name.Substring(0, name.IndexOf("."));
name = name.Substring(name.IndexOf(".") + 1);
}
if (!groups.Contains(group))
{
groups.Add(group, new List<string>());
}
string tmp = "\t\tpublic const int " + name + " = " + reader["msg_def_nu"].ToString() + ";";
tmp = tmp.PadRight(50, ' ');
tmp += "// " + reader["msg_desc"].ToString().Replace("\r\n", "\n").Replace("\n", " ") + " - \"" + reader["msg_text"].ToString().Replace("\r\n", "\n").Replace("\n", " ") + "\"\r\n";
((List<string>)groups[group]).Add(tmp);
}
reader.Close();
conn.Close();
foreach (DictionaryEntry de in groups)
{
string output = string.Empty;
output += "\tpublic static partial class MD"+de.Key.ToString()+"\r\n";
output += "\t{\r\n";
((List<string>)de.Value).Sort();
foreach (string val in (List<string>)de.Value)
{
output += val;
}
output += "\t}\r\n\r\n";
__outputWriter.Write(output);
}
%>
The problem being the connection string is empty string when conn.Open() is called.