Using VB ActiveX.dll files in ASP

Source: Internet
Author: User
Tags comparable knowledge base

No one will work in a more troublesome way without necessary, unless there is no room for choice. So if I'm going 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 approach will move from most of the business logic in your ASP page to a visual Basic ActiveX. dll to improve the performance of the entire Web page.

Reason for using ActiveX. dll

Creating a. dll file in Visual Basic is actually an ActiveX object. This object can be implemented using Microsoft's Component Object Model (COM) technology, and you can use them to create classes related to. dll.

Developers use. dll for a number of reasons, and each project does not contain all the benefits. However, once you take this approach, you will find that you are using ActiveX. DLL technology. Now let's take a look at the advantages of using ActiveX. DLL technology.

Better performance

Without any doubt, one of the main concerns of a developer is complete performance. An ActiveX. dll runs faster than a normal ASP page. Let's take a look at a simple example. An ASP page calculates a variable from 0 to 10000000 and then displays a "done" string that takes 26,087 milliseconds. However, the VB.dll file takes only 100 milliseconds to complete the process. So VB.dll is 260 times times faster than the ASP page.

In such tests, the speed difference is obvious because the ASP runs for 26 seconds and the. dll only needs to run less than 1 seconds. Keep in mind that the difference in speed is primarily related to the amount of work that your code is dealing with, that is, the greater the effort the code performs, the more obvious the difference in speed. If the above test file is enlarged by one time, the speed difference will be more pronounced. ASP pages take 25,156 milliseconds, whereas. dll only takes 70 milliseconds-the latter runs at 359 times times the speed.

A. dll can run faster than an ASP page for two reasons:

. dll is compiled. This means that the file runs in the machine language, which is the speed at which it can be achieved. The ASP page runs code that is processed by a script engine, so that each part must be compiled before being processed.

. dll uses a variable that is declared as a Long data type, which does not require an explanation of the 32-bit processor. The script page uses a Variant variable that must be converted to a number before it can be used in the calculation, which inevitably increases processing time.

Variable declaration method is better

Variable declaration methods can make running faster, in addition to more easily program development, because the variable type does not need to convert. Variables can be declared in the initial state, avoiding the writing of additional conversion code lines.

Source code is hidden

A. dll file can keep your source code hidden from some hacker attacks. An ASP page stores the script in plain text to your Web server. Once someone gets access to your Web site files, the Web page is easily accessible, so your source code is exposed and compromised. Use an ordinary ActiveX. dll file to handle the business logic of your site, thereby preventing malicious people from accessing your source code.

Richer from the development environment

You can also use the Microsoft Scripting Editor to develop ASP scripts. Although this is a more complete tool, it provides only basic scripting features. In contrast, Visual Basic is a rich development environment. In short, the two tools are not comparable-one is a scripting tool and the other is a fully functional development package.

More efficient cross-development

A. dll established in VB can be easily applied to other development environments, such as Microsoft Access. On the other hand, developers must re-establish the task of an ASP page when they are cross developed with other environments.

More Efficient ASP pages

One containing all the business logic can become very verbose.. dll file is a very efficient workaround because it contains all the logic. This management result is simpler and more efficient code.

Some shortcomings

For the most part, the advantages of using ActiveX. dll outweigh its drawbacks, but you should remember that there are some drawbacks. First, ActiveX. dll can in some cases lead to more development time. For example, using a. dll file in a variable calculation takes approximately two seconds, but an ASP page takes only one second. However, this is not very obvious at the beginning stage. The set of well-organized and reusable ActiveX. DLL classes used in the final phase can shorten your development time.

Second, a typical ASP page can easily be changed: you just need to add scripts and save files. Updating A. dll associated with an ASP page is quite complex because you cannot compile a. dll without restarting the network server. However, as a general rule, you can simply restart the network server and then compile or copy a new. dll when the server is running again. Restarting the server takes only one second, so there is no interruption.

Third, the running time must be established on the network server. If you use an ActiveX. DL in an ASP page, but do not have VB run time installed, you can simply use the package and development wizards to install all the processes. Keep in mind that if you or your users want to use ADO, you must install other software, such as MDAC.

Some tips for using ActiveX. dll

Using ActiveX. dll is not difficult, but some simple techniques can make your development process smoother. First, don't forget to register a. dll and use it. To register an ActiveX. dll, you can use the Windows API to invoke the function:

Public Declare Function. DLLSelfRegister Lib "Vb6stkit.dll" (by Val 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 re-register. dll. Compiling an ActiveX. dll assigns a unique identifier to the file. If you copy the source code to another machine and compile it, the identifier will change and map the current machine. This way, every time you copy a. dll to a Web server, you must re-register it.

Using a. dll file sometimes requires you to start the server on the site. The easiest way to manually restart the Network Information Server (IIS) is through Computer Management (a Windows2000 feature) to connect. If you have a Windows 2000 Server Resource Kit, 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, you use the debugging features of Visual Basic, which include allowing you to view all the code when you load an ASP page. You can learn more from the Microsoft Knowledge Base bar's Visual Basic debugging knowledge.

Get more benefits with. dll

A normal ASP page is not comparable to a Web page related to Visual Basic ActiveX. dll, which runs faster and develops more efficiently. This makes it easy for its users to develop in the process. You can develop a better product for your users, and everyone can get more benefit from this kind of management.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.