Marshalling Problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Marshalling Problem

venkatraj82venkatraj82 Posts: 5Member
Im doing a Firewall in C#,on the Process

"byte[] buffer = new byte[20000]; // Start with 20.000 bytes left for information about tcp table
int pdwSize = 20000;
int BufferSize = 100000;
IntPtr lpTable = Marshal.AllocHGlobal(BufferSize);
IntPtr current = lpTable;
int res = IPHlpAPI32Wrapper.GetTcpTable(buffer, out pdwSize, true);
if (res != NO_ERROR)
buffer = new byte[pdwSize];
res = IPHlpAPI32Wrapper.GetTcpTable(buffer, out pdwSize, true);
if (res != 0)
return; // Error. You should handle it

TcpConnexion = new IpHlpApidotnet.MIB_TCPTABLE();
int nOffset = 0;
// number of entry in the
TcpConnexion.dwNumEntries = Convert.ToInt32(buffer[nOffset]);

TcpConnexion.table = new MIB_TCPROW[TcpConnexion.dwNumEntries];"

Iam passing the MIB_TCPROW object to SetTcpEntry...
But iam getting the Following Error
"Can not marshal field Local of type IpHlpApidotnet.MIB_TCPROW: The type definition of this field has no layout information."

Can u anybody help me out???


  • deserteagledeserteagle Posts: 5Member
    : Hi,
    : Im doing a Firewall in C#,on the Process
    : .....


    Sorry, I don't have an answer to your question but I want to make a firewall in C# for my graduation project (Computer Science). I was wondering if you can tell me about any resources that may help (tutorials, source code samples, books, ...) as I couldn't find any.

    This would be really kind of you to help me, thanks in advance.

    Best Regards,
    Wessam Fathi
Sign In or Register to comment.