1

我有一个使用 SimpleAuthentication 的 NancyFX Web 项目,在从终端进行自托管时可以正常工作。当我从单元测试(使用 Xamarin Studio 的 NUnit 运行程序)进行自托管时,我收到异常“在搜索插件时无法反映当前域的程序集”,并带有错误消息“无法加载文件或程序集或其依赖项之一”。重复了很多次。

知道为什么这会失败吗?看起来抛出异常的代码位于https://github.com/SimpleAuthentication/SimpleAuthentication/blob/master/Code/SimpleAuthentication.Core/ReflectionHelpers.cs。我尝试了 IntPtr.Size 测量以确保它们在两种情况下都以相同的 32/64 位运行(它运行 32 位)。

更新:根据建议,我尝试运行一些预发布版本以获得相同的结果,最终得到这些二进制文件:

./Nancy.1.3-Pre1524/lib/net40/Nancy.dll
./Nancy.Authentication.Forms.1.3-Pre1524/lib/net40/Nancy.Authentication.Forms.dll
./Nancy.FlashMessages.1.0.4.0/lib/net45/Nancy.FlashMessages.dll
./Nancy.FlashMessages.Razor.1.0.4.0/lib/net45/Nancy.FlashMessages.Razor.dll
./Nancy.Hosting.Self.1.3-Pre1524/lib/net40/Nancy.Hosting.Self.dll
./Nancy.SimpleAuthentication.0.3.14/lib/net40/Nancy.SimpleAuthentication.dll
./Nancy.Viewengines.Razor.1.3-Pre1524/BuildProviders/Nancy.ViewEngines.Razor.BuildProviders.dll
./Nancy.Viewengines.Razor.1.3-Pre1524/lib/net40/Nancy.ViewEngines.Razor.dll

更新:单独运行 ReflectionHelpers.cs 代码表明唯一无法加载的 DLL 是 MonoDevelop.NUnit。无论如何,这部分不需要 NUnit dll。

我想我应该考虑https://github.com/SimpleAuthentication/SimpleAuthentication/issues/144

4

1 回答 1

0

GetLoadableTypes从@haacked http://haacked.com/archive/2012/07/23/get-all-types-in-an-assembly.aspx/的这篇文章中修复了这个问题

这是公关(https://github.com/SimpleAuthentication/SimpleAuthentication/pull/171

我没有遇到 Nunit 的问题 我遇到的问题Microsoft.Owin.Security.DataProtection.DpapiDataProtector是它没有在 Mono 中实现......

于 2015-08-07T00:11:49.377 回答