Byte array problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Byte array problem

  1. #1
    Join Date
    Feb 2012
    Posts
    3

    Byte array problem

    Hi guys, i have a one byte array in c++ with /cli and return the next error:

    error C2526: 'System::Collections::Generic::IList<T>::default::get' : linking the C function can not return the class 'System::ArraySegment<T>' of C++

    This is my code
    Code:
    	array<System::Byte>^ buffer = gcnew array<System::Byte>(1500);
    	try
    	{
    		server->Receive(buffer);	
    	}
    	catch ( SocketException^ e ) 
    	{
    		Console::WriteLine( "{0} Error code: {1}.", e->Message, e->ErrorCode.ToString() );
    		return ( e->ErrorCode );
    	}

  2. #2
    Join Date
    Feb 2012
    Posts
    3

    Re: Byte array problem

    Sorry by the double post.

    the error its in the line
    Code:
    server->Receive(buffer);

  3. #3
    Join Date
    Feb 2012
    Posts
    3

    Re: Byte array problem

    sorry for the 3 post, this is in the top code
    Code:
    #using <System.dll>
    #using <mscorlib.dll>
    using namespace System;
    using namespace System::Text;
    using namespace System::IO;
    using namespace System::Net;
    using namespace System::Net::Sockets;
    I have clr enabled

    SORRY FOR MY BAD ENGLISH

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,585

    Re: Byte array problem

    Looks like you translated back the error message from a non-English version of VC++. The MSDN page on the error message at http://msdn.microsoft.com/en-us/library/y59181c6.aspx doesn't quite tell me much more than that, but the original message is a bit more informative:

    'identifier1' : C linkage function cannot return C++ class 'identifier2'
    And though that is not the exact original meaning, in the context here the message probably means in essence that a native function can't return a managed type. This is speculation to some extent, though, since the code you posted doesn't really tell the whole story. Is, by any chance, perhaps server->Receive() a native function or is any other native function involved? Since the error message mentions C linkage, the function in question may not be a member of a class at all (or it may be static), and perhaps it's just unmanaged by mistake.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center