c# reflection: How can I invoke a method with an out parameter ?

Posted by ldp615 on Stack Overflow See other posts from Stack Overflow or by ldp615
Published on 2010-03-13T10:51:57Z Indexed on 2010/03/13 10:55 UTC
Read the original article Hit count: 214

Filed under:
|
|

I want expose WebClient.DownloadDataInternal method like below:

[ComVisible(true)]
public class MyWebClient : WebClient
{
    private MethodInfo _DownloadDataInternal;

    public MyWebClient()
    {
        _DownloadDataInternal = typeof(WebClient).GetMethod("DownloadDataInternal", BindingFlags.NonPublic | BindingFlags.Instance);
    }

    public byte[] DownloadDataInternal(Uri address, out WebRequest request)
    {
        _DownloadDataInternal.Invoke(this, new object[] { address, out request });
    }

}

WebClient.DownloadDataInternal has a out parameter, I don't know how to invoke it. Help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection