Also, can I load silverlight page into silverlight control directly instead of using IE control in my application?
No. Currently, Silverlight application need to be hosted on a page.
For the security considerations, you'd better add form authentications to your website. Only validated users can visit the website. Your sample seems a little complex.
Best regards,
Jonathan
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
Yes, my application is little complex, let me clear little bit more it to you.
I am using WTL to create a Silverligh control in a dialog box, It creates successfuly and I can see silverlight configuration menu and can launch Silverlight configuration dialog box through it.
I was woundering if I could put any contents on this control using silverlight COM interfaces? I can set InitParams, also IsVersionSupported() works as well but when I call put_Source() method, it fails and returns E_UNEXPECTED.
Also, my application is not deployed on any Server, my all silverlight pages will exist on local machine and I want to show all silverlight contents on C++ app within hosted silverlight control.
Specifies the URI to use for the source content (the URI can reference a XAML page or a package, depending on whether using JavaScript or managed API respectively).
HRESULT put_Source( BSTR str );
Parameters
str
[in] The URI to use for the source XAML.
Return Values
The method returns an HRESULT.
So what's your code related? Did you have the rights to access the xap file? A simple repro would be better to investigate your problem. Thanks
Best regards,
Jonathan
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
Yes, I used the same function to load silverlight contents but it is returning E_UNEXPECTED. Something is wrong, someone told me that I need to implement IXcpControlHost interface and pass it to hosted control then hosted silverlight control will call when
required but still I don't how can I do that? and what to do next? I gess call put_Source().
If you have any idea how can I pass my implemented IXcpControlHost to Silverlight control using IXcpControl and then call put_Source()?
m_spXcpCtrl->PutInitParams(L"name=source&value=DemoPage1.xap"); works fine but not sure it is correct format
In C#, we do it like this.silverlightControl.InitParameters = "key1=value1,key2=value2,key3=value3"; Do you mean it work? Seems it cannot find the xap file in your code.
Best regards,
Jonathan
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
I mean PutInitParams() works becasue I can get it back. but put_Source() doesnot work at all, It returns E_UNEXPECTED. .XAP file is accessible and I put it on C:\ drive to make sure path and everything is fine.
If you want, I can send you the source code of my sample.
I searched online. But no sample, no document there.
aftabnaqvi
I put it on C:\ drive to make sure path and everything is fine.
I suspect that it is a kind of path related issue. You can post your sample code to somewhere and paste the link here.
Best regards,
Jonathan
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
I was able to load the silverlight page in C++ application using (ATL).
Here are the steps I followed.
1- implement IXCpControlHost/IXCpControlHost2 to communicate with the host.
2- Use CAxHostWindow class to create SL ActiveX control (Typically inherit your class with CAxHostWindow)
Override QueryService() in your derived class and pass interface pointer of IXcpControlHost/IXcpControlHost2 to Host which is hosting SL ActiveX.
AtlAxWinInit();
HRESULT hr;
// Creating the control with IUnnknown might be useful but not in our case. so create SL control directly
hr = CoCreateInstance(CLSID_XcpControl, NULL, CLSCTX_INPROC_SERVER, __uuidof(XcpControlLib::IXcpControl2), (void**)&s_pXcpControl2);
if (SUCCEEDED(hr))
{
CComPtr<IUnknown> spUnkContainer;
hr = CAxHostWindowEx::_CreatorClass::CreateInstance(NULL, IID_IUnknown, (void**)&spUnkContainer);
if (SUCCEEDED(hr)) {
CComPtr<IAxWinHostWindow> pAxWindow;
// Attaching our created silverlight control with static control placed on main dialog box.
hr = pAxWindow->AttachControl(s_pXcpControl2, hWnd);
s_hWnd = hWnd;
}
}
Also, Implement IPropertyBag interface to set "Source" property pointing to your .xap file (file name).
Jonathan She...
All-Star
50156 Points
4951 Posts
Microsoft
Re: send data using POST method to Silverlight page.
Dec 10, 2008 09:39 AM | LINK
Hi Aftabnaqvi,
No. Currently, Silverlight application need to be hosted on a page.
For the security considerations, you'd better add form authentications to your website. Only validated users can visit the website. Your sample seems a little complex.
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
aftabnaqvi
Member
23 Points
33 Posts
Re: send data using POST method to Silverlight page.
Dec 10, 2008 05:32 PM | LINK
HI Jonathan,
Thanks for your response but this link http://msdn.microsoft.com/en-us/library/cc296246(VS.95).aspx shows COM interfaces to create the Silverlight control and LoadRuntime() methods.
Yes, my application is little complex, let me clear little bit more it to you.
I am using WTL to create a Silverligh control in a dialog box, It creates successfuly and I can see silverlight configuration menu and can launch Silverlight configuration dialog box through it.
I was woundering if I could put any contents on this control using silverlight COM interfaces? I can set InitParams, also IsVersionSupported() works as well but when I call put_Source() method, it fails and returns E_UNEXPECTED.
Also, my application is not deployed on any Server, my all silverlight pages will exist on local machine and I want to show all silverlight contents on C++ app within hosted silverlight control.
Any help is appreciated.
Thanks,
Syed
Jonathan She...
All-Star
50156 Points
4951 Posts
Microsoft
Re: send data using POST method to Silverlight page.
Dec 11, 2008 01:25 AM | LINK
Hi Syed,
IXcpControl::put_Source
Specifies the URI to use for the source content (the URI can reference a XAML page or a package, depending on whether using JavaScript or managed API respectively).
Parameters
str
[in] The URI to use for the source XAML.
Return Values
The method returns an HRESULT.
So what's your code related? Did you have the rights to access the xap file? A simple repro would be better to investigate your problem. Thanks
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
aftabnaqvi
Member
23 Points
33 Posts
Re: send data using POST method to Silverlight page.
Dec 11, 2008 05:23 AM | LINK
Hi Jonathan,
Yes, I used the same function to load silverlight contents but it is returning E_UNEXPECTED. Something is wrong, someone told me that I need to implement IXcpControlHost interface and pass it to hosted control then hosted silverlight control will call when required but still I don't how can I do that? and what to do next? I gess call put_Source().
If you have any idea how can I pass my implemented IXcpControlHost to Silverlight control using IXcpControl and then call put_Source()?
Thanks for your help.
Regards,
Syed
Here is my sample code..
GetDlgControl(IDC_AGCONTROL1,
__uuidof(XcpControlLib::IXcpControl2), (void**)&m_spXcpCtrl);VARIANT_BOOL bVal;
bVal = m_spXcpCtrl->IsVersionSupported(L"2.0"); // works fine
if(bVal == VARIANT_TRUE)
{
MessageBox(L"Yes! Supported", L"Silverlight");
}
HRESULT hr = m_spXcpCtrl->LoadRuntime(); // works fine
m_spXcpCtrl->PutInitParams(L"name=source&value=DemoPage1.xap"); works fine but not sure it is correct format
_bstr_t bt = m_spXcpCtrl->GetInitParams(); // gives me back correct params which I set before
BSTR bstr = L"file:///C:\\Work\\DemoPage1\\Bin\\ReleasePage\\DemoPage1.xap"; // I have access to this file.
hr = m_spXcpCtrl->put_Source(bstr); // returns E_UNEXPECTED
NOTE: Same page is accessible if I use IE control to display it in a webpage.
Appreciated!
Thanks,
Syed
IXcpControlHost IXcpControl put_Source()
Jonathan She...
All-Star
50156 Points
4951 Posts
Microsoft
Re: send data using POST method to Silverlight page.
Dec 11, 2008 06:09 AM | LINK
Hi Syed,
In C#, we do it like this.silverlightControl.InitParameters = "key1=value1,key2=value2,key3=value3"; Do you mean it work? Seems it cannot find the xap file in your code.
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
aftabnaqvi
Member
23 Points
33 Posts
Re: send data using POST method to Silverlight page.
Dec 11, 2008 06:31 PM | LINK
Hi Jonathan,
I mean PutInitParams() works becasue I can get it back. but put_Source() doesnot work at all, It returns E_UNEXPECTED. .XAP file is accessible and I put it on C:\ drive to make sure path and everything is fine.
If you want, I can send you the source code of my sample.
Thanks,
Syed
Jonathan She...
All-Star
50156 Points
4951 Posts
Microsoft
Re: send data using POST method to Silverlight page.
Dec 12, 2008 07:53 AM | LINK
Hi Aftabnaqvi,
I searched online. But no sample, no document there.
I suspect that it is a kind of path related issue. You can post your sample code to somewhere and paste the link here.
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
aftabnaqvi
Member
23 Points
33 Posts
Re: send data using POST method to Silverlight page.
Dec 19, 2008 11:48 PM | LINK
Hi All,
I was able to load the silverlight page in C++ application using (ATL).
Here are the steps I followed.
1- implement IXCpControlHost/IXCpControlHost2 to communicate with the host.
2- Use CAxHostWindow class to create SL ActiveX control (Typically inherit your class with CAxHostWindow)
Override QueryService() in your derived class and pass interface pointer of IXcpControlHost/IXcpControlHost2 to Host which is hosting SL ActiveX.
AtlAxWinInit();
HRESULT hr;
// Creating the control with IUnnknown might be useful but not in our case. so create SL control directly
hr = CoCreateInstance(CLSID_XcpControl, NULL, CLSCTX_INPROC_SERVER, __uuidof(XcpControlLib::IXcpControl2), (void**)&s_pXcpControl2);
if (SUCCEEDED(hr))
{
CComPtr<IUnknown> spUnkContainer;
hr = CAxHostWindowEx::_CreatorClass::CreateInstance(NULL, IID_IUnknown, (void**)&spUnkContainer);
if (SUCCEEDED(hr)) {
CComPtr<IAxWinHostWindow> pAxWindow;
hr = spUnkContainer->QueryInterface(IID_IAxWinHostWindow, (void**)&pAxWindow);
// Attaching our created silverlight control with static control placed on main dialog box.
hr = pAxWindow->AttachControl(s_pXcpControl2, hWnd);
s_hWnd = hWnd;
}
}
Also, Implement IPropertyBag interface to set "Source" property pointing to your .xap file (file name).
Thanks,
Syed
Silverlight 2 C++ IXcpControlHost IXcpControl2
elaurentin
Member
15 Points
9 Posts
Re: send data using POST method to Silverlight page.
Mar 10, 2009 05:10 AM | LINK
You may want to look at this article here:
http://www.ernzo.com/WindowlessCont.aspx
You should be able to use it in ATL/WTL application. Silverlight in Windowless mode is also supported.
Cheers,
Ernest Laurentin, MCSD C# .NET
Pascal242
Member
18 Points
9 Posts
Re: send data using POST method to Silverlight page.
Apr 15, 2009 03:43 PM | LINK
Hi Aftabnaqvi,
Could you provide source code for running silverlight through C++ ?. That's what I'm trying to do but the Silverlight control is still empty...
Thank you (expect a gif ;) )