开发者

Is there any way to add references without recompiling in .NET?

I am using a IoC Container (Castle Windsor) to instantiate c开发者_如何学Classes accordingly to the configuration file. If I want to add classes from a new dll that didn't exist when I compiled the project, there is any way to do that without recompiling?

Edit: As this project is a Service Host for WCF service, and the classes that I want to include after compilation are WCF Services I would like also to know if I can include endpoint information about new services without recompiling.


I don't know about Windsor in particular, but I'd expect it to be possible - just specify the full type name including the assembly name:

<component id="foo"
           service="Namespace.IInterfaceName, InterfaceAssembly"
           type="Namespace.ImplementationName, ImplementationAssembly" />


Yes - that's exactly what Castle Windsor is for. I'm using Castle in a project at home and I use it to dynamically load classes from assemblies that probably didn't exist when I created the class.

The trick is that the classes you load have to implement an interface known to your application.

The point of doing this is so that you can switch in and out different functionality as needed. Your project uses ISaveMyData to save stuff and uses Castle Windsor to use either Oracle or MySql depending on maybe what's installed at the client site.

As for WCF, WCF components already must specify an interface they're using (their contract). In the normal configuration for WCF components you can change the endpoint address and other information to point to different components whenever you need to as long as they use the same contract. No Castle Windsor is needed for that. No recompiling is needed either - just make the configuration change and go.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜