2 .NET程序集之间的循环引用 [英] Circular reference among two .net assemblies

查看:444
本文介绍了2 .NET程序集之间的循环引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个组件A和B点。



一个已经存在的参考B和它必须保持这种方式。现在我提出,需要参考A.所以循环引用一些变化到B发生



的细节位:



一个具有需要b中的对话框中被托管的几个属性网格。因此,为了避免这种循环引用问题,我试着定义接口在第三组装网格到急症室;甲乙双方参考,并仅B指接口。



我现在面临的两个问题:




  1. 有太多的自定义数据类型(属性是具体的),这是一个内部定义的网格内,我必须为它们定义中的每一个接口。


  2. 我看到的例子这适用于函数参数例如通过接口调用目标函数传递但是,如何将适合考虑下面的代码 - 我不能将新一ICustomPropertyGridWrapper ...



    对象=新CustomPropertyGridWrapper(...)结果
    m_property.SelectedObject =对象;



< DIV CLASS =h2_lin>解决方案

有关问题1,确实没有其他然后合并两个项目或者做一些代码生成



<解决方案p>对于第二个,您可以通过实施工厂设计模式做。


I have two assemblies A & B.

A has existing reference to B and it must be kept that way. Right now I made some changes to B that need to refer to A. So circular reference occurs.

Bit of details:

A has a few property grids that the dialog in B needs to be hosted. So to avoid this circular reference issue I tried to define interfaces to grids in third assembly to which A & B both refer, and make B only refers to the interfaces.

Two issues I'm facing:

  1. there’s too much custom data types (properties to be specific) inside the grids which are defined inside A and I have to define interfaces for every one of them.

  2. I see example of this works with function parameter e.g. call target function through the interface passed in. But how would it fit considering the following code - I can't new a ICustomPropertyGridWrapper...

    object = new CustomPropertyGridWrapper(...)
    m_property.SelectedObject = object;

解决方案

For issue 1, there is not really a solution other then merge the two projects or do some code generation

For the second, you can do that by implementing the Factory design pattern.

这篇关于2 .NET程序集之间的循环引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆