You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I encounter an error that throw from GetAssemblyFromStringAndCache().
I have setup razorhost in this way.
public class RazorTemplateHelper
{
public static RazorStringHostContainer RazorHost { get; set; }
public static string RenderTemplate(string template, object model/*, out string error*/)
{
if (RazorHost == null)
StartRazorHost(); <-- exception throw from here
//error = "";
string result = RazorHost.RenderTemplate(template, model);
if (result == null)
{
Debug.WriteLine(RazorHost.ErrorMessage);
throw new System.Exception(RazorHost.ErrorMessage);
//error = RazorHost.ErrorMessage;
}
return result;
}
public static void StartRazorHost()
{
var host = new RazorStringHostContainer()
{
//// *** Set your Folder Path here - physical or relative ***
//TemplatePath = Path.GetFullPath(@".\templates\"),
//// *** Path to the Assembly path of your application
//BaseBinaryFolder = Environment.CurrentDirectory
};
// Add any assemblies that are referenced in your templates
host.AddAssemblyFromType(typeof(Microsoft.WindowsAzure.Storage.Table.TableEntity));
<all assembly>
host.AddAssemblyFromType(typeof(Softinn.Razor.EmailAppSetting));
// Always must start the host
host.Start();
RazorHost = host;
}
public static void StopRazorHost()
{
RazorHost?.Stop();
}
}
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: BookingNotification ---> System.IndexOutOfRangeException : Index was outside the bounds of the array.
at System.Collections.Generic.Dictionary`2.Insert(TKey key,TValue value,Boolean add)
at Westwind.RazorHosting.RazorStringHostContainer`1.GetAssemblyFromStringAndCache(String templateText)
at Westwind.RazorHosting.RazorStringHostContainer`1.RenderTemplate(String templateText,Object model,TextWriter writer,Boolean inferModelType)
at Softinn.Razor.RazorTemplateHelper.RenderTemplate(String template,Object model) at C:\<path to project>\RazorTemplateHelper.cs : 13
...
What I mess up from this configuration? I seem like Razorhost doesn't load assembly correctly and causing this unexpected error.
The text was updated successfully, but these errors were encountered:
Not sure what to make of this. If an assembly fails to load you would get a different exception. The error here looks like its failing on the actual add to the dictionary which is odd. Even if the value was null that should work so not sure what's going on there especially given the Index out of Range error.
Hi, I encounter an error that throw from
GetAssemblyFromStringAndCache()
.I have setup razorhost in this way.
What I mess up from this configuration? I seem like Razorhost doesn't load assembly correctly and causing this unexpected error.
The text was updated successfully, but these errors were encountered: