Solved ASP. NET "exception caused by type Initial Value Setting item"

Source: Internet
Author: User

This problem has just been solved in vs2005. It happened in application_start of Global. asax. I originally planned to use timer + threading to automatically schedule some tasks in this event. I have written functions and can use them elsewhere, as soon as the result is put in this box, the error "type Initial Value Setting item causes an exception" occurs.

 

At first, because multiple DLL compilation methods were used, a layer-by-layer query was performed on the Internet. Some people said that the Assembly name was wrong when reflection was used. I also used reflection in several places to dynamically create classes. I checked for a long time and confirmed that there was no error. But the problem persists!

 

There is no way. I am so stupid that I have removed the previously written functions and rewritten them here. Then, we track the debugging step by step and find that part of the object created by reflection runs successfully. However, some methods that were originally appropriate were wrong. The following methods may cause errors:

 

1. All systems are used. web. httpcontext. an error is reported in the current object because the ing of this object is not completed due to the carelessness of MS at the beginning of the application_start event; because I used a method to automatically obtain the URL of the site here, if it does not work properly, I will write the site address in the configuration file or database for direct retrieval, which can also solve the problem.

2. The experience of some netizens is also very important: the initialization of static members is not well done. If an uninitialized static member is used, an error is reported.

 

Experience is just like this. Maybe my understanding is not deep enough. I cannot solve the problem clearly and hope it will help you.

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.