Creating a Web Wrapper for COM and OCX - c#

Today we have a windows application that, using an OCX, creates a web page (visible by a WebBrowser control in a small .NET WinForm application) and communicates through COM to the main application/client. (not relevant but this is Pascal)
I'm currently responsible to re create this application in a web environment so we can have the same functionality shared through Web as the user can see the same in a Web Browser.
The Windows application has almost 4 years on it and I need to re create everything from scratch, and all the bugs/features find in the future in the Windows Application I have to re create them again in the Web...
Ohh well, you can see where this will end.
I was thinking... is there any way I can create a Wrapper, even using 3rd party commercial objects, to:
Communicate with the COM Object
Can expose the content of the OCX
(this in my most confortable language, ASP.NET C#, but other are welcome)
I was thinking out loud, can this be accomplish with a Java Applet? Silverlight 4?
Any ideas or any point to the right road will be appreciated.

You may want to consider using Silverlight 4. Although it's not fully baked (Microsoft announced it as Release Candidate status yesterday or today) it has COM support but will run in a web enabled way.
The fact that your previous application is Windows/OCX tells me that the chief weakness of this approach, which would be platform neutrality, is less of an issue.

Related

Running an exe application from local resource inside ASP .Net Core HTML page

My software is splitted into 2 parts:
ASP .Net Core 3.1 application which is hosted on server
.NET Framework 4.8 WinForms applicaŠ½ion which is deployed on client PC (I can try to place it on server if this greatly simplifies the solution of the problem). The reason why I need this separate application is third-party control that is available only for .NET Framework desktop - WinForms and WPF (unfortunatelly I cannot avoid using or replace it).
Is it possible to run that client PC application inside ASP Net Core HTML page?
I don't need just launch it with System.Diagnostics.Process or similar techniques, I want I want to embed it in a ASP frame somehow. Something like WindowsFormsHost for WFP or ElementHost for WinForms.
Any help is appreciated. Thank you in advance.
Basically, you have these options:
Wrap your desktop app into ActiveX, use IE Tab extension (or similar one), and run ActiveX on the page. The worst one because of, well, ActiveX. In fact, you will not be able to use modern browser features.
Throw away Web UI. If you need desktop app (it doesn't matter why), then use desktop app and Web API at server side. The easiest and obvious one. You're still linked to desktop, so what is the reason to ignore this fact?
Render mentioned control's output at server side, and send the result to browser. This depends on what the control is, what it does, how much interactivity it requires, etc. Also, this assumes, that you must be able to run .NET 4.8 process on your server and communicate with it from .NET Core app.

Convert .Net DLL to Flash Library?

I've made an .Net Dynamic Link Library, written in c#, to be used in Silverlight applications.
Now, I want to have the same kind of functionallity to be used when developing Adobe Flash applications. I'm not that familiar with Flash or ActionScript. I don't even even know if there are some kind of DLL equivalent in Flash/ActionScript.
Any suggestions? Do I have to go the long way, i.e. learn flash and develop this functionallity or, is there a smoother way? A .Net to ActionScript converter?
No.
But you could consider exposing such assembly (DLL) functionalities through a Web Service API, and let both Silverlight and Flash apps access them remotely so both can share the same implementation of your backend.
That will work if the whole assembly it's not doing real-time processing or something like that and the whole Silverlight and Flash apps are browser-based ones. In that case, you can develop an ASP.NET Web API (REST) and do the work in the service.
Later you'll be asynchronously querying the Web API from Flash and Silverlight.

Call managed code from Silverlight application

I have MyDotNet4.dll that user installs as application on machine. In my case this is components that will take care of interfacing with TWAIN scanner.
I also have my Silverlight application with elevated permissions (SL4 OOB or SL5 in/out of browser)
I want to somehow invoke methods of MyDotNet4.dll using Silverlight code. Is that possible? How? Any pointers or sample code?
My idea is to have Silverlight app and if user needs scanning - I will let him download and install real windows app and than I would like to somehow talk to this app from Silverlight.
It may not work, but have a look at this blog, http://netfxharmonics.com/2008/12/Reusing-NET-Assemblies-in-Silverlight, see The Assembly-Level Technique section if (as your question suggests) you do not have the source code for the dll in question. I have faint recollection that I used that method as a test a long while back, but since I had the source I ended up going with the file level approach to share common code between a dll referenced by my Silverlight project and my console app project
Silverlight does have local messaging but that works only between two silverlight apps. See the following for LocalMessaging
Msdn page.
Silverlight OOB and mutiple windows - LocalMessaging
From this similar SO post: Communicating with a Silverlight 4 LocalMessageReceiver from a Desktop Application and this other thread here on the silverlight forums seems you're out of luck and you will have to implement your own communication scheme.
I'm assuming your SL app needs to invoke the scanning app and get the image. You could run your scanning app like this and then have the app drop the picture in a know directory which your SL app can then pick.

How To Get Started With Silverlight?

I want to start silverlight development inside an application which developed by WPF.
Actually we want to add silverlight featuretoan existing WPF project. what should we consider and how todo this
I saw Getting started with Silverlight development and it was not my answer
I mark this as a Community Wiki.
Please clarify your intent. What do you mean by a Silverlight feature ?
Silverlight is a subset of WPF, but is intended for a Web application (i.e. running inside a Web browser, using the .NET framework provided by the browser plug-in), while WPF is meant for a desktop application (i.e. running outside of a browser, using the full .NET present on the disk).
(there is the notion of running WPF inside the browser, but that is still using the full .NET framework).
"Adding" Silverlight to WPF doesn't make much sense because you can accomplish whatever you need to do in regular WPF for the most part. If you already have a WPF application you are enforcing windows and the full .NET client run time so you are going to get any deployment benefits.
I assume what you may be considering (since you mentioned XBAP) is to re-write or recompile your current WPF XBAP application into a Silverlight application? This way you get cross platform web deployment with the full Client run time requirement.
If this is the case then you would not be "adding" to your existing solution. It would be more an exercise in porting the existing application over to Silverlight. With SL3 this is less painful then before (and if SL 4 is an option it will be an even better experience).
My first step would be to simply create a new Silverlight application and begin moving your code over and seeing how far you get.

Can an exe compiled from C# be integrated into a website?

I'm a beginner in programming. I've just made a program called "Guessing Game". And it seems to work fine. Can I integrate it into a website? The CMS that I'm using is Mambo.
===
additional info's
Thanks for all your suggestions.
I still don't have any background about Silverlight, WPF and Java Script which I think sounds good. I'm using Windows and I programmed my "Guessing Game" from Microsoft Visual Studio 2008 and it's using Window application forms.
Yes I guess, for the moment I let it be and start to learn Silverlight or Java Script so that I can integrate it on my website:-)
Thanks for all your input guys:-)
Cheers
A standalone executable cannot be directly integrated into a website. You have a few choices though:
Allow your users to download the executable and run it locally for themselves
Rewrite your program in JavaScript to have it run directly inside of an HTML page, though this could obviously involve a fair amount of reworking
Use Microsoft's Silverlight technology, which allows you to code in C# and produce a web-based frontend similar to Adobe Flash. Your program logic should remain the same and you should only have to change the UI code. In fact if you're already using WPF for the front end, the transition will be even easier.
There are several questions that you still need to answer.
What is your server running? If its not Windows, your exe will not run at all unless it is compatible with Mono or a similar framework for your server's operating system.
How does your "Guessing game" interact with the user? If it is through a WinForms GUI, it will you will not be able to use that GUI on the web. If your game is a WPF application your easiest route may be to port it to Silverlight and serve it up on a web page.
It is typically not trivial to make a regular windows application run in a web environment since on on the web you are really running in the browser, not on Windows.
Yes - in general, when you're talking about software, anything is possible. The question is, how difficult will it be?
To understand that, you have to give us more details about "Guessing Game" including how it is designed, what it's interfaces are, how readily extensible it is, and how prepared you are to change or extend it.
For example, if it is a Windows Forms GUI app, then it will be diifficult to integrate into a web app. If it is a console app, then it will be a little easier. If you can modify it to run as a Windows Service, then a little easier. If you can modify it to accept input from the network (as opposed to getting input solely from the keyboard + mouse), still easier.
You may be able to use reflection to load your assembly into the web application, but most likely, the answer is no.
Your best solution is probably to re-write the game in javascript.
The short answer to your question is now. I'm presuming that since you're running Mambo you're web environment is a LAMP stack. However, you're "Guessing Game" is most likely a Windows application from the sound of it. For a beginner in programming, there is no integration path you're going to be able to take that will allow you to have your game running on your website.
However, here are avenues you can take, which will require a significant amount of time to learn. I'm not saying you shouldn't take time to learn, by all means you should! I'm simply trying to illustrate the fact that this is not something that is going to be doable in a couple of hours.
Silverlight - allows you to run C# code with a WPF like interface on your client's browser and can integrate with your web site through javascript.
Let your client download it from your website and run it off of their PC. This would actually be fairly trivial and would be your quickest option, but it sounds like it's not the kind of integration you were looking for.

Categories