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.