I'm trying to configure Postal in class library project. To do this I need to configure custom EmailService. On Postal webpage there's a snippet for doing this:
// Get the path to the directory containing views
var viewsPath = Path.GetFullPath(@"..\..\Views");
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var service = new EmailService(engines);
(See here: http://aboutcode.net/postal/outside-aspnet.html)
Surprisingly, following error is thrown:
System.ArrayTypeMismatchException occurred HResult=-2146233085
Message=Attempted to access an element as a type incompatible with the array. Source=mscorlib StackTrace: at System.Collections.Generic.List`1.Insert(Int32 index, T item) InnerException:
To be precise - it's thrown during adding FileSystemRazorViewEngine
to ViewEngineCollection
. FileSystemRazorViewEngine
derives from IViewEngine
and ViewEngineCollection
derives from Collection<IViewEngine>
.
And here's stacktrace:
mscorlib.dll!System.Collections.Generic.List.Insert(int index, System.__Canon item) + 0x3e bytes
System.Web.Mvc.dll!System.Web.Mvc.ViewEngineCollection.InsertItem(int index, System.Web.Mvc.IViewEngine item) + 0x89 bytes
I can't figure out what causes the exception.