1

我正在尝试在类库项目中配置 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
消息=尝试以与数组不兼容的类型访问元素。Source=mscorlib StackTrace:在 System.Collections.Generic.List`1.Insert(Int32 索引,T 项) InnerException:

准确地说 - 它是在添加FileSystemRazorViewEngineViewEngineCollection. FileSystemRazorViewEngine源自IViewEngineViewEngineCollection源自Collection<IViewEngine>

这是堆栈跟踪:

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

我无法弄清楚导致异常的原因。

4

1 回答 1

0

我得到同样的错误。我怀疑 Postal 是用稍微不同版本的 System.Web.Mvc 构建的,这是导致 ViewEngine 不兼容的主要项目......但我只有邮政的生产二进制文件......

于 2015-11-23T03:43:43.413 回答