在 Postal 中创建自定义电子邮件服务期间引发的“试图访问与数组不兼容的类型”

本文关键字:访问 数组 类型 不兼容 创建 Postal 自定义 电子邮件 服务期 | 更新日期: 2023-09-27 18:20:36

我正在尝试在类库中配置邮政库项目。为此,我需要配置自定义电子邮件服务。在邮政网页上,有一个执行此操作的代码片段:

// 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: at System.Collections.Generic.List'1.Insert(Int32 index, T item( InnerException:

准确地说 - 它是在向ViewEngineCollection添加FileSystemRazorViewEngine时抛出的. FileSystemRazorViewEngine源于IViewEngineViewEngineCollection源于Collection<IViewEngine>

这是堆栈跟踪:

姆科利布.dll!System.Collections.Generic.List.Insert(int 索引,System.__Canon项(+ 0x3e 字节

System.Web.Mvc.dll!System.Web.Mvc.ViewEngineCollection.InsertItem(int index, System.Web.Mvc.IViewEngine item( + 0x89 字节

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

在 Postal 中创建自定义电子邮件服务期间引发的“试图访问与数组不兼容的类型”

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