Silverlight an alternative to activeX? - c#

I have a question regarding hosting silverlight in asp.net web page. I have a functionality which I tried to achieve through activeX earlier but it didn't work out (hosting related issue etc) so now I am planning to get it done through silverlight.
But I have a doubt here, I want to know how will it work I mean where will silverlight code get executed (Client side or server side) if I call silverlight component's methods through java script ?
Can siliverlight be used as an alternative to activeX controls?

That is a lot of questions.
Silverlight will get executed on client side. You can call webservice though from silverlight which will then execute on server side. Silverlight is comparing to ActiveX "caged" - it is running in sandbox, which will get access only to limited set of functions and local resources (you can use them all, but then you'll have to ask user to run the app in trusted mode, which is not by default). Also it requires plugin in browser (while ActiveX at least for IE does not). You can invoke silverlight application methods trough javascript.
In summary - Silverlight can be alternative to ActiveX for some scenarios.
And as for ActiveX - I recommend do not use them at all, unless you absolutely have to.

Related

Run Javascript+WinJS code from universal windows application on C#

Some time ago we started development of our application for Win8.1/Win10 on Javascript+WinJS (it wasn't my decision to use Javascript, but well, it was done). After a half of the year we published our product to Windows application store, and a few months later we realised we can't implement all features we want on Javascript. So now we decided to switch to C#/XAML. But well, we already have pretty big codebase written on Javascript+WinJS. There was idea we can build new application (UI, new features) on C#, but also reuse current JS code. I've read MSDN a lot and as far as I see it is possible to create class library on C# and use it from JS, but our case is just opposite - I need to encapsulate JS+WinJS in some "component" and use it from our new C# application. Is it possible? I don't even see in Visual Studio such type of project as "Javasctipt library for universal applications".
Things could be not so bad our application was pure JS (I always can put WebView on form and eval some JS code). But WinJS doesn't work in WebView!
So I can't use our JS+WinJS code as "class library" and I can't run it in WebView. Any chances I can use some other approach?
WinJS is just a JS library, it isn't tied to any of Windows Runtime APIs. WinJS can even be used in web development (check this out).
The standart WinJS app template handles the Application.Activated event and invokes WinJS.UI.processAll() in the handler. As long as you host the code in the WebView control, the Application.Activated event doesn't fire because the application is already activated.
The problem solves easily, you just need to invoke WinJS.UI.processAll() explicitly:
<script>
WinJS.UI.processAll();
</script>

send F11 key in code behind in silverlight

I want to use full screen mode in silverlight application but while using silverlight's own full screen feature, keyboard is disabled. So i can use browser's F11 functionality to make the application run in full screen mode.
Can anyone please suggest how to send keys in silverlight??
I suspect that you're in trouble. AFAIK, browsers do not allow programmatic access to window functionality; that is, they won't allow an untrusted application (like Silverlight, or on-page JavaScript) to invoke its "fullscreen" command.
There is also no way to "fake out" the browser as though the user sent the keystroke.
Both of these are serious security issues which is why it's not really possible.
Plausibly with Silverlight running as a trusted application in-browser, it may leverage some of the P/Invoke functionality to get around it, but I suspect that's going too far in your case.
EDIT: By the way, if you are able to host your Silverlight app as a trusted application, then keyboard events are still permitted. However, since you've tagged the question as Silverlight-4.0, I do believe you'll have to upgrade to Silverlight 5 to take advantage of the functionality.

Embed a (Server Side) ActiveX Control in a Web Page (Client Side) C#

I want to embed an ActiveX wrapper (System.Windows.Forms.AxHost) that is created by the server and sent to the client to be displayed in a webpage and kept updated
Is that possible ?
I think it can be done using an object, but not sure how to exactly do it using C# ASP .Net
Reading into your question you may be more specifically asking this:
I want an instance of an activex control that is instantiated on the server rendered on the client, and kept up to date, interactive etc etc as if it had been instantiated on the client.
No this is not possible. When you pass <object classid="sid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"/> from the server you are not passing an instance of that object. You are sending a directive to the client to instantiate and render that object. At the end of the day http communication is just text, not blocks of memory and executable code (which is what an instantiated object is). Anything spit out by the server has to be instantiated on the client. Browsers do so for html tags and might do so objects if they
support the object (java objects require a JVM, activex objects require MS infrastructure)
the object is installed or installable (the
code the has to execute on the client so the code has to get there)
local security settings allow this sort of thing (which is often and
more and more commonly not the case)
ActiveX controls are by their very nature client side (and best avoided for more secure and widely supported technologies for creating robust web UI's like ajax)
I do believe this article may be helpful to you, 'Hosting a Windows Control in a Web form'.
https://web.archive.org/web/20210619191631/https://www.4guysfromrolla.com/articles/052604-1.aspx
I'd like to quote the remarks, though, and keep this points in mind: 'Hosting a Windows Control in ASP.NET has several limitations worth discussing. First it requires both that the client machines have, at minimum, the .NET redistributable installed and be browsing with Internet Explorer 5.01 or later. [...] Second, ASP.NET cannot host Windows Forms. You'll need to abstract those parts to Windows Controls. Lastly, because the Windows Control is not a Web control that can be run at the server, the properties can not be easily set or read during a postback.'

Controlling a GUI application remotely

There's an application written in C# that doesn't have any means of remote controlling. The only use scenario possible is to click the buttons with the mouse to get some result.
I'd like to create a server that would expose some common usage scenario with pre-defined clicking logic. So for example the application has a button "do thing" and I'm willing to make an HTTP (or other) server that would click it when a certain URL is loaded.
The application is intended to be used on Windows, though it should work fine with wine - my primary OS is Ubuntu, but I think that running the app in a VM is a better option. To program the rest of of the logic I can use java, python, ruby, php or node.js (I don't know C#).
What is the best approach to handle this? I would prefer not relying on click at the predefined X*Y position on the screen. Ideally the solution would also allow reading the data back.
You can easily automate the gui using the ui automation api. Check for example the White framework on codeplex
http://white.codeplex.com/
I am not sure however if yiu will be able to easily expose such automated application from an application server. The automation is not possible without explicit user session with visible desktop interface thus limiting your server processing to one active session at a time.

trigger a .net application on the server from web asp.net with parsing some argument

I dont know whether this is possible but it would be great if there is a solution for this:
I have an asp.net webpage. When the user opens a webpage. I would like that webpage to trigger to run a .net application running on the client machine. In addition, during that trigger, that webpage also passes some parameters as arguments to the .net application.
I hope to get some ideas how to achieve this issue somehow?
thanks in advance.
Pretty vague question, but you might look into either:
SignalR - a long polling library for ASP.Net that lets you make calls to client side code from the server side "faking a persistently open connection"
Node.js - a javascript library for the server-side.
I would suggest starting with SignalR
Edit:
https://github.com/SignalR/SignalR
http://chatapp.apphb.com/
See this question: Running application from browser ASP.NET
In short you can't do this with HTML & JS, you may be able to with silverlight depending on what you want to do
Do you have control over the client-side app? If so, Click Once is one approach. Silverlight is another.
For a general purpose solution, the app either needs to be registered with the browser for a specific MIME type (this is how the browser knows to start Acrobat Reader for PDF files, for example), or you would need to create and have your users install an Active-X plug-in (native C++ code, though).

Categories