Hosting ASP.NET Inside Silverlight - silverlight

Yes, I know it is not the intention of Silverlight to host ASP.NET and that the namespaces/classes have been removed, but I have a small personal/pet project where Cassini-like hosting functionality (localhost only is fine) from within Silverlight would be a slick feature.
Can this be made to work somehow? What is missing?

You won't be able to do it because it's not possible to create a listening TCP socket. You can only create client TCP connections.

Related

Socket Programming: Send message from outside Silverlight app into Silverlight app, NOT across two Silverlight apps?

I have little to no experience working sockets save for the last day or so of researching this specific scenario, so bear with me.
I have a standard .NET class library that is run from within a winforms desktop application. I also have a Silverlight Out-Of-Browser application that this class library/DLL must send messages to.
My issue with any example or sample I've found thus far is that they seem to always use the Silverlight application as the client and the outside source as the server.
In my scenario my DLL would need to attempt a socket connection to the OOB silverlight app (if it's running). If that connection succeeds, send a message to it.
So if I'm picturing this correctly, how would I about doing this in a lifecycle perspective?
The DLL would be loaded, and spin up a socket server, that server would then attempt a connection to a socket listener in the OOB silverlight app. If that connection succeeded, send a message?
This would also mean that when the OOB Silverlight app gets fired up, in the application startup, I would create the socket listener and set it to listen?
Thank you for any and all information. Again I've looked at several samples and read more than a few articles and my brain is fried. It's just not clicking with me for some reason.
And keep in mind this is for an "out of browser" instance of a Silverlight application. NOT a web hosted version.
This is the latest sample project I was looking at:
http://www.silverlightshow.net/items/SocketsLight-Silverlight-Sockets-Framework.aspx
You could use COM automation back to front. Silverlight OOB can connect to COM servers. What you want is the reverse - i.e. Silverlight OOB as a COM server. This is how you'd do it.
Design your Winforms app as a COM server that raises events that look like COM commands. e.g. instead of
event ButtonClicked(object sender, EventArgs e);
do this
event SilverlightDoThis(arg1, arg2, ...)

Send simple data from wp7 to winforms application

I want to send simple data (geolocation data to be precise) from Windows Phone 7 application to a windows forms application and use it, as I'm a total beginner in this field I don't know which tools to use.
I searched about wcf services and tested this method but there's some issues: the data is sent from the phone application but isn't sent to the winforms application (guess something is missing)
If your know how to do this in a quick way, or have good tutorials I'll be thankful.
EDIT
I found this tutorial, it show how to connect directly wp7 application and desktop application without using sockets neither wcf service, I'm wondering if it is really works if the application isn't in localhost.
the like for the tutorial: wp7 tutorial
I had a similar problem and so I created a REST/JSON WCF service hosted in IIS with AppHarbor to provide the data. There's hundreds of ways to do it (Ruby/Heroku, etc..), but that particular one fits well within the Microsoft stack. I also needed to share route data and I used the WCF service to wrap the BingMaps services so that route computations are cached and shared. Considering that I had already created a local model, moving it out of my phone project into a service took less than a few hours (including the usual config hiccups, and forgetting to add the appharbor user to my bitbucket repo).
Consuming the service from WinForms (or any client) shouldn't be an issue as the service knows nothing about the client implementation.
Here's a tutorial from code project. REST WCF Service with JSON
I think you would need to implement some sort of server side solution which you could upload to on your Windows Phone and download from on your Windows Form application. This could be achieved using a WCF service which was connected to a server side database.
Another option would be to use sockets and communicate directly with your WinForms application. Check this tutorial on how to use basic sockets on WP7.

Want to use SignalR in Windows Application to sync my clients

i want to create a application where i will use a Windows application as a server and a web application as a client.
Now i want to sync my client(web application) with my server(Windows application).
Both Web and Windows applications are in .NET4.0
Can any one help me on this ?
SignalR supports self-hosting. See https://github.com/SignalR/SignalR/tree/master/SignalR.Hosting.Self
You should be able to start the host directly from inside a Windows application or a Windows service. Your question wasn't clear, but I inferred an application due to the winforms tag on the question.
As long as your application is running, web clients should be able to communicate with your SignalR server code.

WCF Winform Hosting

I have a WCF service hosted in a Winforms application, it's running on a vista machine and I've used netsh to allow the application to listen on port 6003.
I have a client application which can call the WCF service when it is running on the same machine.
The problem is I cannot access the WCF service from any other PC on the network.
I've run netstat and it's definately listening on the port.
I'm using the basicHttpBinding, and it's .Net 4.
Any help would be great.
Regards
Steve
Check the firewall settings on the PC hosting the service. It is probably blocking the access.
Have you tried hitting the services through a web browser?
You can try adding a clientaccesspolicy.xml (and a crossdomain.xml, for good measure) to the root of your server. Check the following link - http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx

What is the current state of Web Sockets for Silverlight applications

From what I've read Web Sockets holds more promise than the duplex polling that is currently available to Silverlight developers for receiving server notifications. However I'm not finding much written in the last 10 months, nor am I finding much at all from a Silverlight perspective.
Please don't answer, that Silverlight can open sockets. I know that --- howerver what I don't know is how silverlight can do that with its web server over port 80 in a firewall friendly way -- all of which is why I'm interested in Web Sockets.
The underlying Silverlight network stack won't allow port 80 to be connected to. The port restrictions are that the port must be between 4502-4534. See Network Security Access Restrictions in Silverlight.
Microsoft recently release a WebSockets prototype part of which includes a Silverlight WebSocket client. One additional restriction with the Microsoft Silverlight WebSocket prototype implementation is that a clientaccesspolicy.xml file must be served up from port 80 on the server that is being connected to.
The Super Websockets project also contains a Silverlight client somewhere. It will most probably have the same restrictions as the Microsoft implementation.
SL4 and 5 do not implement websockets. If browser used to host silverlight plugin supports websockets then you can use browser interop to call websockets api form the silverlight app.
Alternatively a trusted application can connect to any TCP port including port 80.

Resources