Delicious food made from chicken ribs-a truly debuggable ASP. NET Ajax

Source: Internet
Author: User
URL: http://www.cnblogs.com/JeffreyZhao/archive/2007/02/06/ASP_NET_AJAX_Debugging_Project.html

Chicken-like source code

The source code of ASP. NET Ajax is indeed released and the PDB file is provided. That is to say, we can use it for debugging now.

But is it enough? I don't know if my friends have used it to trace the Code. At least I am very dissatisfied after using it.

  • Code is scattered in each file, and IDE's go to definition and other functions cannot be used.
  • The code file cannot be modified at all; otherwise, the line numbers recorded in the PDB cannot correspond to the source code.
  • When viewing the attributes or members of an object during debugging, the following message is often displayed: "cannot evaluate expression because the code of the current method is optimized. ", and the attribute or member Location value cannot be viewed.

The last problem is the most critical, which seriously hinders the debugging process. But what is the solution? The msil has been optimized in the compiled assembly. It is no longer the result of directly compiling the Metafile.

The source code is really a weakness.

 

Chicken ribs can also be delicious

Who said chicken ribs cannot cook delicious food?

The official website provided the source code. Why don't we try to restore it to a C # project? So I created a new C # class library and copied the source code to the project. Then compare compilation errors, running errors, and usage. net reflector view ASP. net Ajax assembly, a little bit to supplement the loss of resources and code, the effort of the two tigers finally perfectly restored ASP. net Ajax assembly.

You can enjoy this food in just a few steps:

  1. Click here to download the project file and web. config file.
  2. Unbind the package and introduce the system. Web. Extensions project to your solution.
  3. Add a reference to the system. Web. exetensions project that was just added to the necessary project in the solution, and delete the reference to system. Web. Extensions. dll in GAC.
  4. Modify web. config to remove all ", version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35. edit the config file or use the file directly.
  5. Recompile.

Now, ASP. NET Ajax has become a project in your solution. You can modify it and debug it as needed. After debugging, remove the reference to this project and re-add the reference of system. Web. Extensions. dll in GAC.

 

Notes for delicious food

Currently, you may need to pay attention to some problems in this project:

1. the debugging project and System. Web. Extensions. dll in GAC cannot be referenced at the same time.

In order not to modify any of your code during debugging, I keep all the source code in the debugging process unchanged, which leads to the reference of system in GAC at the same time in a project. web. extensions. DLL and debug project, a namespace conflict error occurs during compilation. This seems to be an unsolved problem, but the debugging project is almost the same as the Assembly in GAC. You can also use the debugging project for development and re-compile it at release, and the web. change config back.

2. The resource file name and related code are slightly changed.

Because vs is used for compilation (using command line compilation can solve this problem, but it is not easy to debug and use), the name of the resource file has to be changed, such as microsoftajax. JS is changed to system. web. microsoftajax. JS. Correspondingly, since the file name is hard-coded in the source file, I also modified it. As a result, if your program needs to identify these file names, you also need to modify your code when using the debugging project. For example, in my previous article "Important Role of the resolvescriptreference event of scriptmanager", I will determine whether the Assembly references the microsoftajax name in the Assembly. JS file. Now we need to determine whether the file named system is referenced. web. microsoftajax. JS.

In addition, the private method systemwebextensionscontainswebresource of the system. Web. UI. webresourceutil class is used to teach whether the capital verification source file exists. I will change it to return true directly to short-circuit the judgment logic. This code is used to maliciously access the system. web. extensions. A reasonable exception is thrown when resources that do not exist in the DLL program set. We can use ASP normally. net Ajax is not affected by this modification.

In almost all cases, these minor changes do not cause usage problems.

3. The control icon is not compiled into the assembly.

The control icon is not compiled into the Assembly, so that the control in the debugging process, such as updatepanel, does not appear in the toolbar. This does not affect the use, but can be distinguished from the updatepanel in GAC.

4. You must re-compile the Ajax Control Toolkit.

If you need to use Ajax Control Toolkit and debug the project at the same time, you also need to introduce the source file of Ajax Control Toolkit into your solution and modify its reference, use the project for debugging. Finally, you need to re-compile and generate a new assembly.

5. The updatepanel of the debugging project is not supported during the design period.

It seems that we need to work with the design source code to support the design period. I will solve this problem as soon as possible.

 

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.