我正在尝试在类库项目中配置Postal。为此,我需要配置自定义EmailService。在邮政网页上有这样做的片段:
// 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);(见此处:http://aboutcode.net/postal/outside-aspnet.html)
令人惊讶的是,引发了以下错误:
System.ArrayTypeMismatchException发生HResult=-2146233085 Message=Attempted将元素作为与数组不兼容的类型访问。System.Collections.Generic.List`1.Insert(Int32索引,T项目) Source=mscorlib StackTrace: InnerException:
准确地说,它是在向FileSystemRazorViewEngine添加ViewEngineCollection时抛出的。FileSystemRazorViewEngine来自IViewEngine,ViewEngineCollection来自Collection<IViewEngine>。
下面是堆栈跟踪:
mscorlib.dll!System.Collections.Generic.List.Insert(int索引,System.__Canon项)+ 0x3e字节System.Web.Mvc.dll!System.Web.Mvc.ViewEngineCollection.InsertItem(int索引,System.Web.Mvc.IViewEngine项)+ 0x89字节
我不知道是什么导致了这个例外。
发布于 2015-11-23 03:43:43
我也犯了同样的错误。我怀疑Postal构建的System.Web.Mvc版本略有不同,这是导致ViewEngine不兼容的主要项目.但我只有邮政的生产二进制文件..。
https://stackoverflow.com/questions/33545268
复制相似问题