Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I am using unity container for depency injection by attributes using following code

container.RegisterTypes(
                                   AllClasses.FromLoadedAssemblies()
                                       .Where(t => t.GetCustomAttributes<abcAttribute>(true).Any()),
                                   WithMappings.FromMatchingInterface,
                                   WithName.Default,
                                   WithLifetime.PerThread);



Problem is sometimes i get following exception which goes if i clean and rebuild the solution. am i missing something ?
An error occurred when trying to create a controller of type 'ABCController'. Make sure that the controller has a parameterless public constructor.","ExceptionType":"System.InvalidOperationException


What I have tried:

 tried creating parameterless constructor but again get same exception. the exception does not occur when solution is cleaned and build for the first time
<pre>public ABCController()
        {

        }
Posted
Updated 30-May-19 20:33pm

1 solution

Quote:
Problem is sometimes i get following exception which goes if i clean and rebuild the solution. am i missing something ?


Yes. You're missing another clean and rebuild.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900