Last post Jul 15, 2015 07:13 AM by gtscdsi
Jul 11, 2015 05:15 PM|cveld|LINK
At our client we are devising a deployment scenario where we can minimize the regression impact of new or changing controllers onto the others within a particular web api.
While I was working on a solution based on our current idea to split out every controller into a separate webapp, I coincidentally discovered that the current 5.2.3 based stack is capable of "hot plugging" of new controllers! Just by copying a separate class
library assembly (the dll file) with a class derived from ApiController and a method with a senseful RouteAttribute decoration into an existing web api's bin folder.
It is very strange that I cannot find a lot on this topic. I did find various complex solutions using the IAssembliesResolver interface, but we are still a bit reluctant to adapt this approach.
The next strange thing is that we managed to get it working in a fresh 5.2.3 web api build. But in our current 5.2.2 web api, it is not picking up our newly added assembly.
So, now I have a couple of hypotheses:
1. There is a new feature added to 5.2.3, that scans every assembly in the appdomain scope for applied RouteAttribute decorations. Not very likely.
2 .There is an incompatibility going on between the existing 5.2.2 based web api and the class library taking dependencies on the 5.2.3 stack. I have already been fiddling with a class library that is taking dependencies on the 5.2.2 but no success so far,
hence this post.
So question to you guys. Is this approach a valid one which we should pursue further? Are there any means to debug and get to know what is happening and how we can fix it?
Jul 15, 2015 07:13 AM|gtscdsi|LINK
Thank you post here.
I guess you want to make your web api application could dynamic load assembly for new deployed controller and activate new controller instance for request. Please correct me if i'm misunderstanding.
If I'm right about your requirement then I have to say this is really not a very common requirement. And you have said that you found a solution or approach but not detailed information about it then I didn't get the key point of last two question. Could
you provide more detailed information about your approach?
In my understanding, I guess the ControllerFactory should be a good option for you. You could build your new controller into an assembly and inside your web api application should have a IOC component or same behavior to detect or scan specified physical
folder and load assembly to reflect all types and find out the controller you want.