开发者

Handling Types Defined in Plug-ins That Are No Longer Available

I am developing a .NET framework application that allows users to maintain and save "projects". A project can consist of components whose types are defined in the assemblies of the framework itself and/or in third-party assemblies that will be made available to the framework via a yet-to-be-built plug-in architecture. When a project is saved, it is simply binary-serialised to file.

Projects are portable, so multiple users can load the same project into their own instances of the framework (just as different users may open the same MSWord document in their own local copies of MSWord). What's more, the plug-ins available to one user's framework might not be available to that of another.

I need some way of ensuring that when a user attempts to open (i.e. deserialise) a project that includes a type whose defining assembly cannot be found (either because of a framework version incompatibility or the absence of a plug-in), the project still opens but the offending type is somehow substituted or omitted. Trouble is, the research I've don开发者_开发技巧e to date does not even hint at a suitable approach. Any ideas would be much appreciated, thanks.


You will need to make your own serializer using reflection.


This issue is deeply dependent on your architecture. Interfaces and Dependency Injection are used to achieve the "pluggable" architecture you describe, but only you can determine how to "recover" from unavailable type definitions. Your design will need to account for the fact that any component of a project might not load.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜