Running Windows Forms Through In the Browser - c#

I wrote a client/server program using windows form application in visual studio. Now i want to put this program onto a web page, so on the client side they can just go onto any browser and and access the server.
Can i just embed the program i already hav onto a webpage or do i need to rewrite it using visual studio web application or maybe web services?? If so, will it be any different than a regular windows form application?

Sorry, you'll have to rewrite it. Your windows forms application runs on the client, but you want to run it through the browser, where it would have to run on the server.

If you've followed good design principles, the core functionality of your app will not be in the forms, but in classes (hopefully in a class library) that are not specifically tied to the UI. If that is the case, you'll just need to create a web front end (UI), and you can reuse the existing C# classes.
If, however, like many inexperienced developers, you've coupled the underlying logic tightly to the UI - a good example is putting code in the form's .cs file that's not really UI-centric - you're looking at a lot of refactoring, and THEN writing a web front end.

Perhaps you should have a look at ClickOnce deployment. I believe you can utilize it to download the WinForm app from a website.

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>

Executing a C# program in a web form window

I wrote a C# program that works good.
I want to execute that project, in a website, so the main form of my project will be in the web form.
I tried this code in the web application webform:
protected void Page_Load(object sender, EventArgs e)
{
Program.Form1 y = new Program.Form1();
y.ShowDialog();
}
and it works, but my program does not appear in the website, but in another window, and the website stays empty and in continuous linking trial condition.
How can I insert my program into the website window?
What you are calling a "C# Project" is a Windows Forms project. It it not compatible with ASP.NET. You cannot run it that way.
Read about ASP.net, its a tool to develop websites with C#. Programs and websites are 2 different things and you can't run your program in a website. For example, you can't run games in your browser because it is written differently.
Read about it, its very simple to use.
The code in your projects is using the same language (in your case, C#, but it could also be VB) but WinForm applications and Web applications are two different things. The make a long story short, the user interface of the first one will be Windows application installed on a machine while the second one will be displayed in a browser (and hosted on a web server). The bottom line is that those project type cannot be mixed.
However, if you want to reuse some of your code in a Web or a WinForm application, you should consider creating a library project. You'll be able to manage all the code that doesn't refer to specific UI from there and you'll be able to reference it from both of your projects.

Create a process not an application in C#

I've created a simple application that I wish to be a process and not show up as an application inside taskmanager, simply because it is not an application. It was intended to be a process.
You might want to read about Windows Services.
Walkthrough: Creating a Windows Service Application in the Component Designer
Creating a C# Service Step-by-Step: Lesson I
You don't give much information about what you application does, but either Console or Forms will be displayed on the TaskManager, and even as a process it will be shown over the Processes tab so I'm not sure what are your intentions with this.

How can I integrate MS-access UI with .Net web environment

We have a legacy software which was built in MS-Access (UI) but was using Sqlserver 2005 as database server.
The UI in Ms-Access has got Menus with different menu-items. But some of the menu-items doesn't have screens yet (incomplete). So we decided now to move to .net environment (i.e. .net web application). Here is my main question.
Firstly I want start working on the screens in .net (.net web application) which are incomplete for the menu-items in MS-Access. Secondly I will be completing the other screens which are now working in MS-Access UI. So how can I use/call .net web application screens when ever user clicks on menu-items in MS-Access UI.
Please suggest me.
Thanks
It not really practical to integrate screens built in Access with some web based forms. I not sure why or who or what was suggested to you that such an approach is EVER used in our industry.
You can most certainly launch any web form or web site or launch any URL form the Access client running on your desktop. The code to launch that URL is:
Application.FollowHyperlink "path to web form or site goes here"
So you can place a button or menu in an Access form to launch a web form, or even launch eBay if you want. However I do not think the issue (or solution) is the ability to launch some web form, but is having parts of the application talk to each other.
An application becomes useful since all the application parts can tightly talk to each other. Access is a great RAD tool due to great ease as to one form launching a report or another form and passing information. And all of that application can EASY share common code and routines that allows you to accomplish useful business tasks.
So when you click on a detail row in an Access grid of data (continues form), then launching another form to edit the one record takes one line of code. So an application is never really just a single standalone form to edit data, but the talking between the forms and use of code and how those objects dance together is what really makes an application useful. If an application was just forms with no code then I think we would be all out of job in this industry.
The model of how you navigate and build web applications is rather different then how Access works. I mean if you have 5 browsers open, which browser has some form to edit your data and which browser is watching videos on YouTube?
You really cannot approach such a half-baked system in which some forms are in Access and parts of the application are web, based. The only way this is practical is if the web forms do not need to work with or use any of the code in the client forms.
However, you CAN build web forms in Access 2010. In other words, in the Access client you can build both client forms and web forms. The client forms can call and use web forms (they run in the client) as regular forms and things like where clauses etc. will work). When you publish to the web, then ONLY the web forms run. Here is a video of an access application of mine, and note how at the half way point I run the same forms in a web browser:
http://www.youtube.com/watch?v=AU4mH0jPntI
However, the above ability in Access right now cannot work with sql server, and must use SharePoint (or the upcoming office 365).
So no question the concept of moving bits and parts out of an application to being web based makes sense (so your concept of not moving ALL of the applicaton out to the web makes sense). However, the parts being moved out to the web must make sense as web or stand alone and not require integration with the client forms (at least during use).
In other words if you have a legacy payroll system in Access now, but want employees to enter their payroll hours, then that new web part is separate from the payroll system. And no question the payroll system could take and pull hours from the new employee hour entry system that is web based.
However, the idea that menus and parts of the client based application will seamlessly launch and use the web browser parts makes no sense at all . Again this makes zero sense and you are barking up the wrong tree here. As noted, if the web part is really a separate business process, then there are some possibilities here.
Last but not least, you can certainly build a set of web services (application business code and logic that is separate from the UI) on the .net web site. This separate business layer could then be used by both the Access client forms and the web forms. However, once again such a setup likely suggests that you better off to build the application as web based anyway as the web based forms can talk and use the business code with greater ease then the client forms can – only exception here again is if you using Access web services, then both web or client forms can use the stored procedures and business routines you write to run server side.
Last but not least, perhaps your problem(s) are solved by increased connectivity, and not really the need for web based? I address this question in the following article of mine.
http://www.kallal.ca/Toweb/Index.html

C# Making a Frontend to a Console Program?

I wrote a console program in c# that takes up to three files as input, and does some data calculations on them.
I'd like to make a simple frontend that allows the user to easily
import files - basically choose up to three files to be routed to the backend code
change settings - I have about 10 settings that I'm currently storing in an app.config file. maybe a simple settings box would be nice
see what's going on - the console program shows some status messages that might be useful to display on a GUI
I have practically no experience with windows forms or GUI design, so I really don't know where to begin. I compiled the backend stuff into a *.dll and am currently playing around in design mode of sharpdevelop...but i really have no idea how to get the two to work together.
any pointers would be greatly appreciated!
The usual pattern, in cases like these, is to make the main features of the application into a class library and call that from a wrapping executable, such as a console app, winforms app or webforms app (if possible). That way you can easily adapt the interface as needed and simply route input and output to and from the class library.
Edit: I realize this isn't a very indepth answer, but I hope it helps to get started at least, together with any other answer that may arrive.
If you want to get started with GUI design in .NET, I recommend you choose WPF (Windows Presentation Foundation). This is the latest technology released in the UI/graphics area by Microsoft and is where everything is heading now. (Windows Forms won't be obsolete for a long time, though it is surely but slowly becoming deprecated.) I noticed however that you are using SharpDevelop, which doesn't yet have real support for WPF (as far as I know), whereas it certainly does for WinForms. If there's any chance you can use Visual Studio, I recommend you begin by learning WPF. You have the advantage of not being confused by previous experience with the styles and methodologies of WinForms, so it would very much be the right way to go.
Whichever you wish to learn, the Getting Started page of WindowsClient.NET (the official MS site for both WinForms and WPF) would be a great resource. There's also a few MSDN articles on getting started with WPF.
Hope that helps.
Have you tried Visual Studio Express editions? They're free and come with a designer for either WinForms or WPF applications.
As a first pass you'll need 3 text areas for the filenames, with associated buttons to bring up the file open dialog (it doesn't actually open the file just returns the filename).
A label to display the status - updated from your worker code.
Then either the various radio buttons, check boxes etc for your configuration settings.
Oh and don't forget the "Start" button to set off your process.
If your process takes a while you ought to use a background worker thread. You can then implement a "Cancel" button to safely abort the process and tidy up if it goes wrong.
There will be optimisations and reorganisations that you can do once you've got it working.
Your question is quite indistinct. If you're asking about working with GUI, you should read some book on Windows Forms.
And if you're asking about how to put your dll in your new windows forms application, then you should just add a reference to it in winforms project's properties and then use classes from dll's namespace.

Categories