Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi

I have a problem in convert dll unmanaged(c++) byte * to managed.net(webservice)


Example:


C#
STDMETHODIMP CCMSTest::Test1(BYTE* bstr)
{
        for(int i=0;i<6;i++)

        bstr[i-1]=i;


    return S_OK;
}


who can used under code in managed.net(webservice) ???????????????????????????

Please Help me
Posted
Comments
Sergey Alexandrovich Kryukov 29-May-13 1:49am    
What exactly do you mean by "convert"? Write the same in C#, or something?
—SA

Note that even your C++ code is badly written. Why the immediate constant 6 is used (hard-coded)? Why don't you pass the length? What if the number of elements in the array is less? Besides, for i=0, your code will crash because the index will be out of range (-1). No, this is not a valid code.

In C#, it could be something like:
C#
class CmsTest {
    
    static void FirstTest(byte[] data) {
        for (int index = 0; index < data.Length; ++index) {
            // do something correct with data, data[index],
            // not what is written in your invalid C++ code
        }
    }
 
}


Good luck,
—SA
 
Share this answer
 
v2
Comments
Maciej Los 29-May-13 2:04am    
+5!
Sergey Alexandrovich Kryukov 29-May-13 2:16am    
Thank you, Maciej.
—SA
C#
STDMETHODIMP CCMSTest::Test1(BYTE* bstr, USHORT iLen)
{
        for(int i=0;i<ilen;i++)>

        bstr[i-1]=i;


    return S_OK;
}



}

who can convert byte * unmanaged in managed.net(webservice)
who can used under code in managed.net(webservice) ???????????????????????????

Please Help me
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900