No one will use more troublesome ways to work without unnecessary circumstances, unless there is no room for choice. So if I want to tell you that there is a simple technology that can make your ASP development faster and more efficient, you must be particularly interested in this. This method will transfer from most Business Logic in your ASP page to a visual basic activityx .dll to achieve the performance of the entire webpage.
The reason for using Activex .dll
The establishment of a .dll file in Visual Basic was actually an ActiveX object. This object can be implemented using Microsoft's component object model (COM) technology, and you can also use them to build a class related to .dll.
There are many reasons for developers to use .DLL, and each project does not include all advantages. However, once you use this method, you find that you are using Activex .dll technology. Let's take a look at the superiority of using Activex .dll technology.
Better performance
Without any questions, the main problem of a developer's attention is complete performance. Compared with an ordinary ASP page, an Activex .dll runs faster. Let's take a look at a simple example. A ASP page calculates a variable from 0 to 100,000, and then a "Done" string requires 26,087 milliseconds. However, the VB.DLL file can complete this process in only 100 milliseconds. So VB.DLL is 260 times faster than the ASP page.
In this test, the difference between speed is obvious, because ASP runs for 26 seconds, and the .dll only needs to run less than 1 second. Please keep in mind that the difference in speed is mainly related to the workload of the code to handle, that is, the greater the workload of the code execution, the more obvious the difference in speed will be. If the above test file doubles, the speed difference will be more obvious. The ASP page requires 25,56 milliseconds, but the .dll only required 70 milliseconds -the latter runs at a speed of 359 times.
There are two reasons for the faster than the ASP page :dll:
.dll was compiled. This means that the file is running in the machine language, which can reach the speed it can reach. The ASP page runs the code processed by a script engine, so that each part must be compiled before processed.
The .dll uses a variable that is declared as a long and integer data type, which does not require the explanation of 32 -bit processors. The script page uses a variant variable. This variable type must be converted into a number before it can be used in the calculation. This will inevitably increase the processing time.
Variable declaration method is better
The method of variable declaration can make the running faster. In addition, program development can be easier, because the variable type does not need to be converted. The variable can be declared in the initial state, which avoids writing an additional conversion code line.
Source code is hidden
A .dll file can hide your source code and prevent some hackers from attacking. A ASP page stores the script program with pure text to your network server. Once someone gets the right to access your network site file, the webpage is easily accessed, so your source code is public and damaged. Use an ordinary Activex .dll file to handle the Business Logic of your site, so as to prevent people who do not have a good intention to access your source code.
Rich in the development environment
You can also use Microsoft script editor to develop ASP script. Although this is also a relatively complete tool, it only provides basic script characteristics. Instead, Visual Basic is a rich development environment. In short, these two tools are not comparable -one is the script tool, and the other is a fully functional development software package.
High -efficiency cross development
The .dll established with VB is easy to apply to other development environments, such as Microsoft's Access. On the other hand, when crossing with other environments, developers must re -establish a task of ASP page.
ASP page with higher efficiency
One of the Business Logic contains all long. .dll file was a very efficient solution because it contained all logic. This management result is: simpler and efficient code.
Some disadvantages
For most, the advantages of using Activex .dll are better than its shortcomings, but you should remember that there are still some disadvantages. First, Activex .dll can lead to more development time in some cases. For example, using the .dll file in the variable calculation requires about two seconds, but the ASP page only takes one second. However, this is not obvious at the beginning. A well -organized and reusable Activex .dll class used in the final stage can shorten your development time.
Second, the typical ASP page is easy to be changed: you only need to add scripts and save files. Update a .dll that was linked to the ASP page was quite complicated, because you could not compile the.dll without re -start the network server. However, as a general rule, you can simplify the network server simplified, and then compile or copy a new .dll when the server run again. It only takes one second to restart the server, so there will be no interruption.
Third, operating time must be established in the network server. If you use an ASP page to use an ASTIVEX .dl but not installed VB to run time, you can simply use the software package and the development orientation to install all the processes. Remember, if you or your users want to use ADO, you must install other software, such as MDAC.
Some techniques of using Activex .dll
It is not difficult to use Activex .dll, but some simple techniques would make your development process smooth. First, don't forget to register a .dll and use it. In order to register an Activex .dll, you can use the Windows API to call the function:
Public Declare function .dllSelfister lib vb6stkit.dll (by value lp.dllName as string) as integer
After changing a .dll, if you need to add a new class or copy the source code to another development environment, you must register .dll. Compile a Activex .dll to allocate a unique identifier to file. If you copy the source code to another machine and compile it, the identifier will change and map the current machine. In this way, every time you copy .dll to the network server, you must register it again.
Using the .dll file sometimes requires your site to start the server. The easiest way to re -start the network information server (IIS) of artificial land is to connect through computer management (a Windows2000 function). If you have the Windows 2000 server resource toolbox, you can also use the service.vbs tool to run these batch files:
c:
CD/
CSCRIPTSERVICE.VBS /X /N W3SVC /S IISMACHINENAME
pause
CSCRIPTSERVICE.VBS /G /N W3SVC /S iISMACHINENAME
When debugging .dll, using Visual Basic debugging features, these features include allowing you to view all code when you load an ASP page. You can learn more in the debugging knowledge of Visual Basic in the Microsoft Knowledge Base column.
Use .dll to get more benefits
An ordinary ASP page is unable to compare with a webpage related to VISUAL BASIC ACTIVEX.DLL. The latter runs faster and has higher development efficiency. This makes its users go smoothly during development. You can develop a better product for users, and everyone can get more benefits from this management.
------------------------------------------------ ----------------------------------------------------------------------------
The author of this article Susan Sales Harkins is an independent and free software development consultant and the author of many articles about database development and network technology. The recent book about her is: SQL: Access to SQL Server (APress), MasterIn Dreamweaver MX Databases (Sybex), and Absolute Beginner''s Guide to Microsoft Access 2002 (Que). Drew WUTKA is a network developer of Microsoft Access/Visual Basi of MARLONWENSTRIES.