[英]How do I call a function in a C++ Dll from C# that has void* callback and object parameter
[英]How do I recieve an array of objects in c++ from a c# DLL call
我正在使用“混合模式” c ++,並調用我無法控制的ac#dll中的函數。 我有所有在ac#test exe中運行的調用,但是無法將將數組返回到混合模式c ++的調用進行轉換。 我不需要在C ++中修改數組,只需閱讀它即可。
我在c#中有2個選項,在c ++中工作就足夠了。
這是從c#dll獲取數組的基本c#exe調用
CoefficientGroup[] G = Cfg.GetCoefficientGroups();
在我的C ++中,我嘗試了許多^選項,但無濟於事-它無法編譯
CoefficientGroup^[] G = Cfg->GetCoefficientGroups(); etc etc
我也在c#中嘗試了這種方法,效果很好
System.Collections.IEnumerator eG = Cfg.GetCoefficientGroups().GetEnumerator();
while (eG.MoveNext())
{
CoefficientGroup X = eG.Current as CoefficientGroup;
}
但是在c ++中,我找不到辦法在c ++中執行“ as”強制轉換(如下所示)
System::Collections::IEnumerator^ eG = Cfg->GetCoefficientGroups()->GetEnumerator();
while (eG->MoveNext())
{
CoefficientGroup^ X = (CoefficientGroup)eG->Current;
}
好吧,我自己找到了一個答案。 我錯過了這個CoefficientGroup ^ X =(CoefficientGroup ^)eG-> Current的帽子; 雖然仍然對數組聲明的答案感興趣
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.