question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Registering Classes.FromThisAssembly() doesn't do anything

See original GitHub issue

Trying to register all classes with the following syntax does nothing, although it compiles just fine and there’s nothing obvious to indicate why it wouldn’t register all types in my assembly.

container.Register(Classes.FromThisAssembly());

The correct syntax, I’ve finally discovered, is to use the .Pick() descriptor

container.Register(Classes.FromThisAssembly().Pick());

It seems to me that that the registration should either default to use Pick() if no other descriptor is provided or throw an exception indicating the operation isn’t allowed. A better solution would be, if possible, to prevent passing in the return type of any FromAssembly()) method into the registration method, although I suspect that would be fairly more complicated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Jan 22, 2018

@danquist - Any questions we will help you out.

1reaction
dquistcommented, Jan 22, 2018

Sure thing, I’d be willing to do that. Might take me a week or two to set up my environment and submit the PR though since I haven’t contributed to Windsor before 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Registering a class from an unreferenced assembly with ...
Have you tried something like this container.Register( Classes .FromAssemblyNamed("MyProject.Web").Where(t => t.FullName == "MyProject.Web.
Read more >
c# - Registering dependency implemented in separate ...
I have a project with a Business Layer (WizBang.BL) that contains nearly all of my application logic. It communicates with a Data Layer...
Read more >
Error 19 - Cannot register assembly. Exception has been ...
No, there is no code in my class constructor. - No, I am not mixing versions of .NET - Yes, registering does work...
Read more >
Dynamically Loading Assemblies for Dependency Injection ...
I try to register class library but the method System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); is not ...
Read more >
Dependency injection for a library with internal dependencies
In the web site's composition root, they just need to register the default repository locator. IMO the web site doesn't even need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found