?
Solved

Using ActiveX dll vs. ASP include for functions.

Posted on 2003-03-21
12
Medium Priority
?
250 Views
Last Modified: 2013-11-18
I'm just learning how to create ActiveX DLL's for use in ASP pages.

My question is:
Is it better to create all of my functions in a DLL
vs. using Include statements to load a page of functions.

I understand it's much easier to change the ASP page if my code needs
to change, but I am more interested in speed and performance.

For example, is it a bad idea to put a simple function such as:

Public Function GetDomain(strEmailAddr As String) As String
  Dim sFnd() As String
  sFnd = Split(strEmailAddr, "@")
  GetDomain = sFnd(1)
End Function

in the DLL or should I just leave it as ASP?

What about text that is never changed (but required in the application), I had the idea of using a public property get to return the text?
0
Comment
Question by:Frog357
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 400 total points
ID: 8180811
>>but I am more interested in speed and performance.<<

There is some overhead involved in making a call to a DLL, so from a performance point of view, it is better to use it for "heavier" calls.  When I've used DLLs, I pass the parameters received by the ASP page and process and output with Response object in the DLL.  Optimized compiled code will run quickly in a DLL as compared to the interpreted VBScript code in your ASP page.

>What about text that is never changed (but required in the application), I had the idea of using a public property get to return the text? <

I don't think there is any advantage to storing constant values in the DLL.  There are many advantages to doing all processing and output in the DLL, however.
0
 
LVL 4

Author Comment

by:Frog357
ID: 8180872
Can you provide me with a few examples on using the standard ASP objects in the DLL?  Or a link would be great!

I would like to access:
Request.Form
Response.Redirect
Session.Abandon

I increased points to 100.

My production server is a Pentium Pro 200 so I've set the option to Favor PPro CPU, I'm trying to get as much from this box as possible!
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8181011
If you don't have to hide your source code, you don't have to call dll, put everything in ASP page.

It is lot more easy to debug your problem.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8181125
Also, you wouldn't have problem with version compatibility and updating existing code is an easy process.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8181158
Add a reference to the Microsoft Active Server Pages Object.  Then you can use the standard ASP objects either by passing them into the DLL as a parameter to a function call. Otherwise, you can create them using ObjectContext as per this MS article:

http://support.microsoft.com/default.aspx?scid=KB;en-us;q238274
0
 
LVL 2

Expert Comment

by:rzweifel
ID: 8181181
Here is a walkthrough that should get you started on referencing the intrinsic ASP objects from VB:

http://www.devguru.com/features/tutorials/CreateActiveX/tutCreateActiveX_VB.html

I disagree with EDDYKT. I think VB code is a lot easier to debug than ASP code.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8181201
Eddy, I find it easier to write code and debug in VB.  Updating existing code and maintaining compatibility require work and planning, but this is also true of coding an entire application in VBScript; I'm not convinced my approach is the more difficult.  

Also of note, one has to stop and restart the web server for each compile, this can cause a problem if your production server has to have zero downtime.
0
 
LVL 2

Expert Comment

by:rzweifel
ID: 8181341
If you're "interested in speed and performance" the best way to go might be ASP.NET. Also, you could update dlls without shutting down IIS.
0
 
LVL 4

Author Comment

by:Frog357
ID: 8181429
Thanks PaulHews,
The information provided is enough to help me complete my project.  I am very familiar with optimizing VB code and I've always hated explicit variants in VBScript, I guess I'll recreate everything and see how it flies ;)  I am still planning on holding constants in the DLL just to keep the ASP pages clean.  Plus the ability to optimize the DLL for use with a Pentium Pro makes me think I might be able to squeeze a little more from my work!

Sometimes people who teach themselves get tired and thats when EE comes to save the day!
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8181618
>>I am still planning on holding constants in the DLL just to keep the ASP pages clean.<<

If that's an issue, you can also do a simple include to include the contents of a text file.

<!--#include file="myfile.txt"-->

This inserts the contents of the text file into the HTML stream, the same as if it was entered into the file instead of the include directive.  You can include asp code and functions in the same way.
0
 
LVL 4

Author Comment

by:Frog357
ID: 8181737
That is what I was currently using, but I'm planning on switching a lot of code into a dll for reusability and security.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8181831
Yeah, unfortunately, you can't do:
Response.Write "<!--#include file='myfile.txt'-->"
But string and file manipulation is very easy within VB so it's easy to emulate.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question