は、cの私のDLL関数++C#のコードは、C++ DLL関数を呼び出していません(パラメータとしてクラスポインタを持っている)、呼び出すことになっていることを、私はC++のコードを変更しないでください
static bool t72CalculateRMDMethodResult(const double AccountBalanceAtSetup,
const long ClientCurrentAge,
const char Frequency,
double * pRMDMethodResult,
IRSLookupTable & LookupTable)
です前述の下には、私はC++上記の関数のパラメータ以下
class IRSLookupTable
{
public:
struct IRSLookupTableRow
{
unsigned int Key;
double Value;
};
IRSLookupTable(const char * pFilename);
IRSLookupTable(const struct IRSLookupTableRow Table[], const unsigned int NumEntries);
virtual ~IRSLookupTable();
bool LookupValueByKey(const unsigned int Key, double * Value);
virtual bool ParseLine(char * Buffer, unsigned int * Key, double * Value);
bool IsInitialized();
private:
typedef map <unsigned int, double> IRSLookupTableData;
IRSLookupTableData m_IRSTableData;
bool m_bInitialized;
};
として渡されたポインタを持つクラスは、私はC#でのC++ DLL関数と呼ばれ、私はそれが正しいかどうかを確認していないと私はどのようにありますdll関数に入ることができません
[DllImport("t72CalculatorDLL.dll", ExactSpelling = true, EntryPoint = "t72CalculateRMDMethodResult")]
public static extern bool t72CalculateRMDMethodResult(double AccountBalanceAtSetup, int ClientCurrentAge, char Frequency, double* pRMDMethodResult, [MarshalAs(UnmanagedType.LPStruct)] ref IRSLookupTable LookupTable);
これは
[DataContract]
public unsafe class IRSLookupTable
{
public struct IRSLookupTableRow
{
public uint Key;
public double Value;
};
public IRSLookupTable()
{
m_bInitialized = true;
}
public IRSLookupTable(char* pFilename)
{
// uint Key;
// double Value;
// m_bInitialized = false;
// Debug.Assert(pFilename);
// if (pFilename ==null)
//{
// // return without setting the flag to true
// return;
//}
//// open the file
//std::ifstream InputFile(pFilename);
//if (! InputFile)
//{
// // return without setting the flag to true
// return;
//}
//while (InputFile.getline(&gTmpBuffer[0], BUFFERSIZE))
//{
// if (! ParseLine(gTmpBuffer, &Key, &Value))
// {
// m_IRSTableData[Key] = Value;
// }
// else
// {
// // return without setting the flag to true
// return;
// }
//}
//m_bInitialized = true;
}
public IRSLookupTable(IRSLookupTableRow* Table, uint NumEntries)
{
m_bInitialized = false;
for (uint i = 0; i < NumEntries; i++)
{
m_IRSTableData[Table[i].Key] = Table[i].Value;
}
m_bInitialized = true;
}
~IRSLookupTable() { }
public bool LookupValueByKey(uint Key, double* Value) { return true; }
public virtual bool ParseLine(char* Buffer, uint* Key, double* Value) { return true; }
public bool IsInitialized() { return true; }
private SortedDictionary<uint, double> m_IRSTableData;
private bool m_bInitialized;
}
は、誰もがこれで私を助けてくださいすることができ、C++、私はC#で書かれているクラスの定義0は、私はC#に完全に新しいです。
これは* some *タイトルです! – Nick
コードのC#側にIRSLookupTable型を定義しましたか?もしそうなら、その定義を含めることができます。 – user957902
はい私は、上記の質問に定義を提供しました – krishna555