Frank Schwieterman
Frank Schwieterman

Reputation: 24480

SimpleAuthencation throwing "Failed to reflect on the current domain's Assemblies while searching for plugins"

I have a NancyFX web project using SimpleAuthentication that works fine when self-hosting from the terminal. When I self-host from unit tests (NUnit runner with Xamarin Studio), I receive exception "Failed to reflect on the current domain's Assemblies while searching for plugin" with error message "Could not load file or assembly or one of its dependencies." repeated many times.

Any idea why this would fail? This looks like the code throwing the exception is at https://github.com/SimpleAuthentication/SimpleAuthentication/blob/master/Code/SimpleAuthentication.Core/ReflectionHelpers.cs. I tried a IntPtr.Size measurement to make sure they are running in the same 32/64 bitness in both cases (it is running 32-bit).

UPDATE: Per recommendation, I tried to run some prerelease builds to the same resulting, ending up with these binaries:

./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

UPDATE: Running the ReflectionHelpers.cs code in isolation shows that the only DLL failing to load is MonoDevelop.NUnit. The NUnit dll is unneeded for this part anyhow.

I suppose I should contemplate https://github.com/SimpleAuthentication/SimpleAuthentication/issues/144

Upvotes: 1

Views: 111

Answers (1)

jjchiw
jjchiw

Reputation: 4445

I fixed this with GetLoadableTypes from this post from @haacked http://haacked.com/archive/2012/07/23/get-all-types-in-an-assembly.aspx/

And here it's the PR (https://github.com/SimpleAuthentication/SimpleAuthentication/pull/171)

I didn't had the problem with Nunit I had the problem with Microsoft.Owin.Security.DataProtection.DpapiDataProtector that it's not implemented in Mono....

Upvotes: 0

Related Questions