[Frog frog recommendation] how to solve some minor problems after. NET 1.1 is transplanted to. NET 2.0

Source: Internet
Author: User
Tags object serialization
[Frog frog recommendation] how to solve some minor problems after. NET 1.1 is transplanted to. NET 2.0

After discussion by members of the wawaCRM project team, the wawaCRM project decided to use the new. NET platform for construction.

Microsoft Visual Studio 2005 + C #2.0 + SqlServer2005 + ASP. NET 2.0

This decision has not yet been fully discussed, and some problems have not been fully taken into account. For example, a project created in this way will have a strong dependence on a specific platform and become an enterprise-level project, product-level projects should not use immature technologies and test platforms. But these problems are. NET 2.0 technology and related tools are not very important and cannot be solved. We believe Microsoft will do everything well, which solutions will help us provide.

Today, I started to port the CMP architecture in the 1.1 environment to the 2.0 Environment, and I want the CMP architecture to add the [transaction management] and [concurrent processing] features, however, there were some minor problems during the compilation into vs.net 2005. Now let's talk about the solutions to these problems.

1. Set strong names for the Assembly

Each project in the CMP architecture has a link to SharedAssemblyInfo. cs file and set some attributes of the Assembly in that file, including strong names. This file contains the following statements to set strong names of each Assembly.
[Assembly: AssemblyKeyFile (@ "... \ .... \ GadgetsWarehouse. SNK")]

A warning is prompted during the result compilation, as shown below.
Use the command line option "/keyfile" or appropriate project settings to replace "AssemblyKeyFile"

Originally, vs.net 2005 does not advocate the use of the [assembly: AssemblyKeyFile ()] attribute. You need to set a strong name key file for the assembly in the [signature tag] In the attribute of each project (not a solution.

2. Get the changes to the current thread ID
The error handling module in the CMP architecture needs to obtain the thread information, exception information, stack information, and Persistent Object serialization information of the current application when an exception occurs to generate an error report, the following statement is used to obtain the ID of the current thread. Of course, this code is not allowed by default. You need to set the registry and Machine. config file.

AppDomain. GetCurrentThreadId ()

Result compiler warning:

"System. appDomain. getCurrentThreadId () "expired:" AppDomain. getCurrentThreadId has been deprecated because it does not provide a stable Id when managed threads are running on fibers (aka lightweight threads ). to get a stable identifier for a managed thread, use the ManagedThreadId property on Thread. http://go.microsoft.com/fwlink? Linkid = 14202"

After google. "AppDomain. replace the GetCurrentThreadId () method. "System. threading. thread. currentThread. you can use the ManagedThreadId attribute.

Reference link:

Http://lists.ximian.com/pipermail/gtk-sharp-list/2005-September/006374.html

3. Changes to access program Configuration

When writing error logs, the CMP architecture needs to read the log storage path in the. Config file and use the following code.
String errorLogBaseDir = System. Configuration. ConfigurationSettings. deleettings ["ErrorLogBaseDir"];
The following warning message is displayed during compilation.
"System. Configuration. ConfigurationSettings. deleettings" is out of date: "This method is obsolete, it has been replaced by ConfigurationManager. deleettings"

Later, I used the [Obsolete ("here to read the config file", false)] attribute to mark the method, but the code that calls this method marked a warning, and I was dizzy.

Later I understood that these warnings were caused by System. appDomain. getCurrentThreadId (), System. configuration. configurationSettings. class Members such as AppSettings are marked with the Obsolete attribute, so these custom warnings are generated during compilation to warn people that they can use updated class members to replace existing functions.
Later, I googled a foreigner's blog and got the result.
Replace the "System. Configuration. ConfigurationSettings. configurettings" indexer under. net 1.0 with the "System. Configuration. ConfigurationManager. configurettings []" indexer under. net 2.0.

References
ConfigurationManager Gotcha
Http://www.irishdev.com/blogs/kieranlynam/archive/ 2005/05/17 /728. aspx
 

ConfigurationManager Gotcha

Quick Gotcha... Up to now, you use the ConfigurationSettings. Your ettings property to read an entry from the specified ettings section of the config file.
In ASP. NET 2.0, this property is marked as obsolete; you must now use the ConfigurationManager class. However, this does not seem to exist in the System. Configuration namespace. Annoying.
Actually, it does exist in this namepsace, but you must add a referene to the System. Configuration assembly first (this assembly is not one of the default references ).

Section: From. from. net 1.1. some minor changes may occur when porting the net 2.0 code, but most of Microsoft has provided prompts that as long as the English skills are good, it will be solved quickly and will not be like me, to solve these three small problems, I used Kingsoft to translate them for a long time. Then I went to QQ to ask this question, and I went to google to search for it. Then I translated and understood it. After a long time, I got the answer. In addition, I advise some new programmers to learn english well. Don't even know the English letters except the C # keywords.

 

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.