Web and Windows application

bungpeng

Senior Contributor
Joined
Sep 10, 2002
Messages
906
Location
Malaysia
I would like to develop a application which can easy fit in both Web and Windows application, is it possible?

Can I use .NET to do it? or what is the best choice?

Thank you very much
 
I've got a similar scenario that my team is tackling right now. .NET is clearly the best option you've got. By working with a common business layer and event model, much of the presentation code will be the same. For example, with most events, there's no difference from winform to webform.
 
If your core application code and logic is in a class library, you could access that from either a windows or web application and separate interface from code quite effectively.
 
Is that what you mean?
for example: I use VB.NET to develop my application logic in class, then for Web application, I can use ASP.NET to call VB.NET's Classes? any example for this?

Previously, we may use VB to code the application logic in "DLL" file, then we may call from ASP, is it now still the same? I afraid there might have problem if we try to register "DLL" in registry, furthermore, Web Hosting Service not allow us to register "DLL" in their server
 
You can compile a class library into .dll files (which is exactly what you reference in projects under References to get you robjects, such as System). To start creating a class library you can go to File -> New -> Projects -> Visual Basic Projects -> Class Library.

If you already have classes built somewhere else (ie; built a few classes for a project) you can use them to create your class library instead of creating whole new ones by simply adding them to your class library by going to Project -> Add Existing Item.

The way I understand .NET, .dll files are not registered as they were in previous versions of VB which makes portability insanely awsome.

I have not played with ASP.NET either, so this is an assumption based on what the other 2 said.. you can create your core application in a Class Library then compile it, then you can use that library in your ASP or Windows project by simply referencing the library just like you would with anything else (there are 3 tabs in the reference which are .NET, COM and Project, go to the Project tab and browse for the compiled Class Library). After it's referenced you can use it just like any other objects, matter of fact it'll even give you full details about the Class Library in the object browser.

Hope that helps and hopefully I'm correct in a few of my assumptions. :) If not one of the local .NET gurus will surely correct me.
 
Wyrd is correct. .NET DLLs don't require the COM based registration we're used to, and in fact you can have multiple versions of the same component installed side-by-side. In fact, you can even use the DLLs on your web server as long as ASP.NET is installed. No additional server-side steps need to be taken, such as running RegSvr32. Using a DLL in ASP.NET is a bit different from using one in ASP, so feel free to start another thread about doing so.
 
If no need to register DLL, then how to deliver our application+DLL files to customer? how the program know which DLL file it needs?

Thank you Wyrd and Derek Stone !!!
 
By default, .NET looks for referenced assemblies in the same directory as the executing assembly. Much simpler than COM, with better version control.

Next, it will look in the GAC (Global Assembly Cache). Then it will look in any subdirectories you have configured in the executing assembly.

Microsoft have coined the phrase "XCopy Deployment" because theoretically all you have to do to deploy .NET apps is copy them across.
 
bungpeng said:
Is that what you mean?
for example: I use VB.NET to develop my application logic in class, then for Web application, I can use ASP.NET to call VB.NET's Classes? any example for this?
This is what I mean, but it's even better. In many cases, the code will be able to be the same in both thick and thin client. For a simple example, if I had a calculator business class that I wanted to expose in both clients I could create textbox controls in each and the event handling code would be the exact same.
Code:
   Private Sub cmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalculate.Click
        Dim calc As New Calculator()
        txtAnswer.Text = calc.Add(txtFirstNum.Text, txtSecondNum.Text)
    End Sub
I just created this sample and copied this cmdCalculate event handler from the winForm app to the webForm app and it works without modification. Now obviously state issues will eventually creep up but no doubt this is cool stuff.
 
Back
Top