-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lamar & Alba ServiceRegistry not working in Release mode #98
Comments
When you say it fails in Release mode, what is the actual failure? |
🤦♂️ I really should have included that!
|
My initial guess is that it has to do with the scan of The |
You might be onto something there. If I change the Startup to explicitly use the public void ConfigureContainer(ServiceRegistry services)
{
services.AddMvc();
services.Scan(_ =>
{
_.TheCallingAssembly();
_.WithDefaultConventions();
//_.LookForRegistries();
});
services.IncludeRegistry<RestRegistry>();
} What I want to do is see the output of |
You can do it in the
|
Well that is a helpful snippet even if we don't figure this out! Anyway the output of Debug: 2018-10-22 21:17:54 [Verbose] All Scanners
================================================================
Assemblies
----------
* LamarBug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Conventions
--------
* Default I[Name]/[Name] registration convention
* Lamar.Scanning.Conventions.FindRegistriesScanner
Assemblies
----------
* LamarBug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Conventions
--------
* Default I[Name]/[Name] registration convention
No problems were encountered in exporting types from Assemblies And Release 2018-10-22 21:17:02 [Verbose] All Scanners
================================================================
Assemblies
----------
* Microsoft.AspNetCore.Hosting, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Conventions
--------
* Default I[Name]/[Name] registration convention
* Lamar.Scanning.Conventions.FindRegistriesScanner
No problems were encountered in exporting types from Assemblies The remaining question I guess is...why the initial scan only finds the |
Given all the information we have, I would venture to guess this has something to do with the way Alba is running the tests in the different configurations. As I said, the So you can work around this, for both modes by adding into your scan: There are a bunch of other methods on the scanner that you can use to add different assemblies to the scanning if neither of those is perfectly suitable, but the bottom line is that you have to make sure you are scanning all the right assemblies. |
Yes, I am aware of how the scanning works, so have updated my test to get around this. I've "moved" this issue to the Alba repo as that seems to be the more likely cuplrit, so will shut this issue. Thanks for your help in diagnosing! |
For the record, I am not certain if this is a bug in Alba or Lamar.
The problem occurs when an object is registered outside the
Startup
class in Alba, using.ConfigureServices
, and aServiceRegistry
within the application makes use of that registered type to register another type. This works fine when run inDebug
mode, but underRelease
, the second type registration is not found. Probably better explained with a test...ServiceRegistries
, and make theservices.For...
call inConfigureContainer
, it works in both Release and DebugPackage versions used:
I can upload the test project if that would help.
The text was updated successfully, but these errors were encountered: