views:

270

answers:

2

Hello,

Is there any C# equivalent of the code below?

 HRESULT hr;
    ActiveXSite* pSite;
    pSite = CAxWindowlessHost<CMainDlg>::CreateControlSite(L"AgControl.AgControl", NULL, IDC_AGCONTROL1);
    if ( pSite != NULL )
    {
        // disable right-click!
        pSite->SetAllowRClick(false);
        // set moniker URL
        CComBSTR bstrUrl("file:///C:/Temp/SilverlightDemo.xap");
        pSite->SetUrl(bstrUrl);

        PropertyParams props;
        props.push_back( PropertyParam(L"Windowless", L"true") );
        props.push_back( PropertyParam(L"MinRuntimeVersion", L"2.0.31005.0") );
        props.push_back( PropertyParam(L"Source", static_cast<LPCWSTR>(bstrUrl)) );
        props.push_back( PropertyParam(L"InitParams", L"") );
        hr = pSite->ActivateAx(rc, false, props);
    }
+2  A: 

It seems that you want to embed a silverlight application into your own desktop application. I didn't do it myself, but it seems somewhat related to

Host silverlight in the Windows.Forms...

Also try googling for "embedding silverlight in winforms". One possibility would be to embed a web-browser control and load the silverlight app into it.

PS: There is certainly no direct equivalent of your code since ATL is a C++-technology ...

MartinStettner
>>t seems that you want to embed a silverlight application into your own desktop applicationI tried to host AgControl from COM component in winform but it's not working for some reasons. But Windows Media Player is working fine. Strange.
dont want to use SL2 OOB and Web Browser. I'm checking ISilverlightViewer, IXcpControlHost and IXcpControlHost2 interfaces. My C++ knowledge is so limited. :(
A: 

Apart from the rather perverse approach of trying to make a line for line transcription using P/Invoke, the expected way of using native COM objects from .net is via the Runtime Callable Wrapper

Steve Gilham