简体   繁体   English

如何通知托管DLL有关托管应用程序类型的信息

[英]How can I inform my managed DLL about my managed application types

I have a situation where I have a C# Managed DLL that is handling incoming real time data. 我遇到的情况是我正在处理传入的实时数据的C#托管DLL。 The DLL filters and saves up to 200 of the most recent data points in a FIFO. DLL过滤并在FIFO中最多保存200个最新数据点。 I also have a C# application that on occasion needs to get some of the data from the DLL. 我也有一个C#应用程序,有时需要从DLL中获取一些数据。 I can easily setup methods in the DLL to return single values of the built in data types. 我可以轻松地在DLL中设置方法以返回内置数据类型的单个值。

What I need is a way to pass a reference to my user defined type (EX: List ) to the DLL and have it fill it in. I cannot seem to find any way to tell the DLL about my types and the compiler complains that I do not know what I am doing. 我需要的是一种将对我的用户定义类型(EX:List)的引用传递给DLL并将其填充的方法。我似乎找不到任何方法可以告诉DLL有关我的类型的信息,并且编译器抱怨我不知道我在做什么。 This is true. 这是真的。 I have tried everything I can find on the internet. 我已经尝试了所有可以在互联网上找到的东西。

Further my application already has a reference to the DLL so that it can start it up and respond to events, therefor I cannot add a reference to my application within the DLL without creating a circular reference. 此外,我的应用程序已经具有对DLL的引用,因此它可以启动它并响应事件,因此,在不创建循环引用的情况下,我无法在DLL中添加对我的应用程序的引用。

So how can I inform my managed DLL about my managed application types? 那么,如何将我的托管应用程序类型通知托管DLL? The end goal is to be able to pass an ObservableCollection and have the DLL fill in MyObject with data from its local cache of data points. 最终目标是能够传递ObservableCollection并使DLL使用来自其数据点本地缓存的数据填充MyObject。

When searching the internet it seems that the managed to unmanaged scenario outweighs the managed to managed scenario by 98 plus percent. 在Internet上搜索时,托管到非托管方案似乎比托管到托管方案多了98%。

Any ideas would be greatly appreciated. 任何想法将不胜感激。

To compile my comment as an answer: 汇编我的评论作为答案:

You should have (naming is just ilustrative): 您应该有(命名只是说明性的):

  • DataContract.dll with the definition of your types. 带有您类型定义的DataContract.dll。
  • BusinessLogic.dll with the logic. 具有逻辑的BusinessLogic.dll。
  • And Application.exe with your presentation logic. 以及具有演示逻辑的Application.exe。

DataContract.dll can then be referenced by both - BusinessLogic.dll and Application.exe. 然后可以同时引用DataContract.dll-BusinessLogic.dll和Application.exe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM