EDN Admin
Well-known member
Hi,
I met some trouble when calling a COM interface via C#, an exception is throw by C#. Access protected memory exception.
Following steps are what i did:
After add the COM lib , the function in C# is like:
<pre class="prettyprint void StartConversationEx(CALL_INFO callInfo, CALL_MEDIA_TYPE eCallMediaType, out int pConversationId);
[/code]
CALL_INFO structure is like:
<pre class="prettyprint public struct CALL_INFO
{
public ADDRESS_TYPE addressType;
public string bstrValue;
}[/code]
and following code is what i called this function
<pre class="prettyprint CALL_INFO callInfo;
callInfo.addressType = ADDRESS_TYPE.ADDRESS_URI;
callInfo.bstrValue = m_strTelnos;
m_phone.StartConversationEx(callInfo, CucRtxExeProviderLib.CALL_MEDIA_TYPE.CALL_MEDIA_VIDEO,
out m_ConversationId);[/code]
The function in C++ is like following:
<pre class="prettyprint virtual HRESULT __stdcall StartConversationEx (
/*[in]*/ struct CALL_INFO callInfo,
/*[in]*/ enum CALL_MEDIA_TYPE eCallMediaType,
/*[out]*/ long * pConversationId ) = 0;
CALL_INFO
{
enum ADDRESS_TYPE addressType;
BSTR bstrValue;
};
[/code]
<br/>
May i know why there is an exception and how to call this function?
View the full article
I met some trouble when calling a COM interface via C#, an exception is throw by C#. Access protected memory exception.
Following steps are what i did:
After add the COM lib , the function in C# is like:
<pre class="prettyprint void StartConversationEx(CALL_INFO callInfo, CALL_MEDIA_TYPE eCallMediaType, out int pConversationId);
[/code]
CALL_INFO structure is like:
<pre class="prettyprint public struct CALL_INFO
{
public ADDRESS_TYPE addressType;
public string bstrValue;
}[/code]
and following code is what i called this function
<pre class="prettyprint CALL_INFO callInfo;
callInfo.addressType = ADDRESS_TYPE.ADDRESS_URI;
callInfo.bstrValue = m_strTelnos;
m_phone.StartConversationEx(callInfo, CucRtxExeProviderLib.CALL_MEDIA_TYPE.CALL_MEDIA_VIDEO,
out m_ConversationId);[/code]
The function in C++ is like following:
<pre class="prettyprint virtual HRESULT __stdcall StartConversationEx (
/*[in]*/ struct CALL_INFO callInfo,
/*[in]*/ enum CALL_MEDIA_TYPE eCallMediaType,
/*[out]*/ long * pConversationId ) = 0;
CALL_INFO
{
enum ADDRESS_TYPE addressType;
BSTR bstrValue;
};
[/code]
<br/>
May i know why there is an exception and how to call this function?
View the full article