NewLife/X

主线升级到.Net4.5,为了更好的使用await/async。
次线保留.Net4.0
Stone 编写于 2016-08-01 23:57:53
共计: 修改45个文件,增加245行、删除289行。
修改 +6 -6
修改 +1 -1
修改 +17 -6
修改 +3 -18
修改 +0 -51
修改 +0 -5
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +2 -0
修改 +2 -0
修改 +2 -0
修改 +3 -0
修改 +2 -0
修改 +3 -1
修改 +2 -0
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +3 -1
修改 +1 -0
修改 +16 -4
修改 +10 -0
修改 +16 -4
修改 +2 -1
修改 +3 -2
修改 +31 -31
修改 +18 -5
修改 +17 -0
修改 +4 -2
修改 +0 -7
修改 +0 -115
修改 +1 -4
修改 +1 -0
修改 +1 -0
修改 +15 -4
修改 +13 -4
修改 +0 -1
修改 +14 -4
修改 +6 -6
diff --git a/NewLife.Core/IO/IOHelper.cs b/NewLife.Core/IO/IOHelper.cs
index a79b32d..7a267b2 100644
--- a/NewLife.Core/IO/IOHelper.cs
+++ b/NewLife.Core/IO/IOHelper.cs
@@ -21,10 +21,10 @@ namespace System
             if (outStream == null) outStream = new MemoryStream();
 
             // 第三个参数为true,保持数据流打开,内部不应该干涉外部,不要关闭外部的数据流
-#if NET45
-            using (var stream = new DeflateStream(outStream, (CompressionLevel)9, true))
-#else
+#if NET4
             using (var stream = new DeflateStream(outStream, CompressionMode.Compress, true))
+#else
+            using (var stream = new DeflateStream(outStream, (CompressionLevel)9, true))
 #endif
             {
                 inStream.CopyTo(stream);
@@ -82,10 +82,10 @@ namespace System
             if (outStream == null) outStream = new MemoryStream();
 
             // 第三个参数为true,保持数据流打开,内部不应该干涉外部,不要关闭外部的数据流
-#if NET45
-            using (var stream = new DeflateStream(outStream, CompressionLevel.Optimal, true))
-#else
+#if NET4
             using (var stream = new GZipStream(outStream, CompressionMode.Compress, true))
+#else
+            using (var stream = new DeflateStream(outStream, CompressionLevel.Optimal, true))
 #endif
             {
                 inStream.CopyTo(stream);
修改 +1 -1
diff --git a/NewLife.Core/Model/IPlugin.cs b/NewLife.Core/Model/IPlugin.cs
index f147aaa..047c495 100644
--- a/NewLife.Core/Model/IPlugin.cs
+++ b/NewLife.Core/Model/IPlugin.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 using NewLife.Log;
 using NewLife.Reflection;
 #if __MOBILE__
@@ -118,7 +119,6 @@ namespace NewLife.Model
                 {
                     // 如果有插件特性,并且所有特性都不支持当前宿主,则跳过
                     var atts = item.GetCustomAttributes<PluginAttribute>(true);
-
                     if (atts != null && atts.Any(a => a.Identity != Identity)) continue;
 
                     list.Add(item);
修改 +17 -6
diff --git a/NewLife.Core/NewLife.Core.csproj b/NewLife.Core/NewLife.Core.csproj
index 897d884..5109f8c 100644
--- a/NewLife.Core/NewLife.Core.csproj
+++ b/NewLife.Core/NewLife.Core.csproj
@@ -12,29 +12,40 @@
     <AssemblyName>NewLife.Core</AssemblyName>
     <FileAlignment>512</FileAlignment>
     <BuildPackage>true</BuildPackage>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
     <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\..\Bin4\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
-    <DocumentationFile>..\..\Bin4\NewLife.Core.XML</DocumentationFile>
+    <DocumentationFile>..\..\Bin\NewLife.Core.XML</DocumentationFile>
     <DebugType>full</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
     <ErrorReport>prompt</ErrorReport>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <DocumentationFile>..\..\Bin\NewLife.Core.XML</DocumentationFile>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
     <OutputPath>..\..\Bin4\</OutputPath>
     <DefineConstants>TRACE;NET4</DefineConstants>
-    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
     <DocumentationFile>..\..\Bin4\NewLife.Core.XML</DocumentationFile>
     <Optimize>true</Optimize>
     <DebugType>pdbonly</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
     <ErrorReport>prompt</ErrorReport>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
   </PropertyGroup>
-  <PropertyGroup />
   <ItemGroup>
     <Reference Include="Microsoft.VisualBasic" />
     <Reference Include="System" />
修改 +3 -18
diff --git a/NewLife.Core/Reflection/AttributeX.cs b/NewLife.Core/Reflection/AttributeX.cs
index 8cc25b1..3cf117a 100644
--- a/NewLife.Core/Reflection/AttributeX.cs
+++ b/NewLife.Core/Reflection/AttributeX.cs
@@ -10,7 +10,7 @@ namespace System
     public static class AttributeX
     {
         #region 静态方法
-#if NET4 && !__MOBILE__
+#if NET4
         /// <summary>获取自定义属性</summary>
         /// <typeparam name="TAttribute"></typeparam>
         /// <param name="member"></param>
@@ -41,7 +41,6 @@ namespace System
 
             return avs[0];
         }
-#endif
 
         private static DictionaryCache<MemberInfo, DictionaryCache<Type, Array>> _miCache = new DictionaryCache<MemberInfo, DictionaryCache<Type, Array>>();
         private static DictionaryCache<MemberInfo, DictionaryCache<Type, Array>> _miCache2 = new DictionaryCache<MemberInfo, DictionaryCache<Type, Array>>();
@@ -66,24 +65,9 @@ namespace System
             });
             if (atts == null || atts.Length <= 0) return new TAttribute[0];
 
-            //return atts.Cast<TAttribute>().ToArray();
             return atts as TAttribute[];
-
-            //var key = "";
-            //var type = (member as Type) ?? member.DeclaringType ?? member.ReflectedType;
-            //if (type != null)
-            //    key = String.Format("{0}_{1}", type.FullName, member.Name);
-            //else
-            //    key = String.Format("{0}_{1}", member.Module.Assembly.FullName, member.MetadataToken);
-
-            //key = String.Format("{0}_{1}_{2}", key, typeof(TAttribute).FullName, inherit);
-
-            //return (TAttribute[])_miCache.GetItem<MemberInfo, Boolean>(key, member, inherit, (k, m, h) =>
-            //{
-            //    var atts = m.GetCustomAttributes(typeof(TAttribute), h) as TAttribute[];
-            //    return atts == null ? new TAttribute[0] : atts;
-            //});
         }
+#endif
 
         private static DictionaryCache<String, Object> _asmCache = new DictionaryCache<String, Object>();
 
@@ -103,6 +87,7 @@ namespace System
                 return atts == null ? new TAttribute[0] : atts;
             });
         }
+
         /// <summary>获取成员绑定的显示名,优先DisplayName,然后Description</summary>
         /// <param name="member"></param>
         /// <param name="inherit"></param>
修改 +0 -51
diff --git a/NewLife.Core/Reflection/ScriptEngine.cs b/NewLife.Core/Reflection/ScriptEngine.cs
index a933c78..648c97a 100644
--- a/NewLife.Core/Reflection/ScriptEngine.cs
+++ b/NewLife.Core/Reflection/ScriptEngine.cs
@@ -396,59 +396,8 @@ namespace NewLife.Reflection
             }
 
             var provider = CodeDomProvider.CreateProvider("CSharp");
-            //var arg = (String)provider.CreateGenerator().Invoke("CmdArgsFromParameters", options);
-            //XTrace.WriteLine(arg);
-            //#if !NET4
-            //            Check35(provider);
-            //#endif
             return provider.CompileAssemblyFromSource(options, classCode);
         }
-
-        //void Check35(CodeDomProvider provider)
-        //{
-        //    // 如果是2.0,为了使用扩展方法,直接调用3.5编译器
-        //    if (XTrace.Debug) XTrace.WriteLine("当前环境是2.0,为了使用扩展方法等,准备调用3.5编译器");
-        //    // 先找到2.0路径,隔壁就是3.5,如果不存在,则下载并解压
-        //    var dir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();
-        //    var fdir = dir.AsDirectory().Parent.FullName;
-        //    dir = fdir.CombinePath("v3.5");
-        //    var file = dir.CombinePath("csc.exe");
-        //    if (!Directory.Exists(dir) || !File.Exists(file))
-        //    {
-        //        var url = "http://www.newlifex.com/showtopic-1348.aspx";
-        //        XTrace.WriteLine(".Net 3.5未安装,准备下载绿色版 " + url);
-        //        var client = new Web.WebClientX(true, true);
-        //        try
-        //        {
-        //            var zip = client.DownloadLink(url, "csc_v3.5", dir.EnsureDirectory());
-        //            if (File.Exists(zip))
-        //            {
-        //                NewLife.Compression.ZipFile.Extract(zip, dir);
-        //            }
-        //        }
-        //        catch (Exception ex)
-        //        {
-        //            XTrace.WriteException(ex);
-        //        }
-        //    }
-        //    if (File.Exists(file))
-        //    {
-        //        Environment.SetEnvironmentVariable("COMPLUS_InstallRoot", fdir);
-        //        Environment.SetEnvironmentVariable("COMPLUS_Version", "v3.5");
-        //        //Environment.SetEnvironmentVariable("COMPLUS_Version", "v4.0.30319");
-
-        //        //var type = TypeX.GetType("RedistVersionInfo");
-        //        //var dic = new Dictionary<String, String>();
-        //        //dic.Add("CompilerVersion", "v3.5");
-        //        //var path = (String)type.Invoke("GetCompilerPath", dic, "");
-        //        //XTrace.WriteLine(path);
-
-        //        //var gen = provider.CreateGenerator();
-        //        var gen = provider.GetValue("generator") as ICodeGenerator;
-        //        var provOptions = gen.GetValue("provOptions", false) as IDictionary<string, string>;
-        //        if (provOptions != null) provOptions["CompilerVersion"] = "v3.5";
-        //    }
-        //}
         #endregion
 
         #region 执行方法
修改 +0 -5
diff --git a/NewLife.Core/Serialization/Json/IJson.cs b/NewLife.Core/Serialization/Json/IJson.cs
index a82b282..223b5a2 100644
--- a/NewLife.Core/Serialization/Json/IJson.cs
+++ b/NewLife.Core/Serialization/Json/IJson.cs
@@ -1,11 +1,6 @@
 using System;
 using System.Collections.Generic;
-using System.Reflection;
 using System.Text;
-using System.Web.Script.Serialization;
-using System.Xml.Serialization;
-using NewLife.Log;
-using NewLife.Reflection;
 
 namespace NewLife.Serialization
 {
修改 +3 -1
diff --git a/NewLife.Core/Threading/AsyncMethodBuilderCore.cs b/NewLife.Core/Threading/AsyncMethodBuilderCore.cs
index 54ec2e7..f156325 100644
--- a/NewLife.Core/Threading/AsyncMethodBuilderCore.cs
+++ b/NewLife.Core/Threading/AsyncMethodBuilderCore.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Diagnostics;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     internal struct AsyncMethodBuilderCore
@@ -96,4 +97,5 @@ namespace System.Runtime.CompilerServices
             return result;
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/AsyncMethodTaskCache.cs b/NewLife.Core/Threading/AsyncMethodTaskCache.cs
index a6b629b..bb12d91 100644
--- a/NewLife.Core/Threading/AsyncMethodTaskCache.cs
+++ b/NewLife.Core/Threading/AsyncMethodTaskCache.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Threading.Tasks;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     internal class AsyncMethodTaskCache<TResult>
@@ -69,4 +70,5 @@ namespace System.Runtime.CompilerServices
             return CreateCompleted(result);
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/AsyncServices.cs b/NewLife.Core/Threading/AsyncServices.cs
index d7ede3e..2d6c71c 100644
--- a/NewLife.Core/Threading/AsyncServices.cs
+++ b/NewLife.Core/Threading/AsyncServices.cs
@@ -3,6 +3,7 @@ using System.Runtime.CompilerServices;
 using System.Threading;
 using System.Threading.Tasks;
 
+#if NET4
 [assembly: TypeForwardedTo(typeof(AggregateException))]
 [assembly: TypeForwardedTo(typeof(OperationCanceledException))]
 [assembly: TypeForwardedTo(typeof(CancellationToken))]
@@ -58,4 +59,5 @@ namespace System.Runtime.CompilerServices
 			return exc;
 		}
 	}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/AsyncTaskMethodBuilder.cs b/NewLife.Core/Threading/AsyncTaskMethodBuilder.cs
index 358ef35..44dca3f 100644
--- a/NewLife.Core/Threading/AsyncTaskMethodBuilder.cs
+++ b/NewLife.Core/Threading/AsyncTaskMethodBuilder.cs
@@ -1,6 +1,7 @@
 using System.Diagnostics;
 using System.Threading.Tasks;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     /// <summary>��ʾ�����������ڷ���������첽������</summary>
@@ -256,4 +257,5 @@ namespace System.Runtime.CompilerServices
             return singleton.FromResult(result);
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/AsyncVoidMethodBuilder.cs b/NewLife.Core/Threading/AsyncVoidMethodBuilder.cs
index b0abf7e..0cdc7ec 100644
--- a/NewLife.Core/Threading/AsyncVoidMethodBuilder.cs
+++ b/NewLife.Core/Threading/AsyncVoidMethodBuilder.cs
@@ -3,6 +3,7 @@ using System.Diagnostics;
 using System.Threading;
 using System.Threading.Tasks;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     /// <summary> ��ʾ�����������ڲ�����ֵ���첽������</summary>
@@ -165,4 +166,5 @@ namespace System.Runtime.CompilerServices
             }
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/AwaitExtensions.cs b/NewLife.Core/Threading/AwaitExtensions.cs
index 07f00f5..3cc5049 100644
--- a/NewLife.Core/Threading/AwaitExtensions.cs
+++ b/NewLife.Core/Threading/AwaitExtensions.cs
@@ -1,3 +1,4 @@
+#if NET4
 using System;
 using System.Diagnostics.Contracts;
 using System.Threading;
@@ -98,4 +99,5 @@ public static class AwaitExtensions
 
         return new ConfiguredTaskAwaitable<TResult>(task, continueOnCapturedContext);
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/ConfiguredTaskAwaitable.cs b/NewLife.Core/Threading/ConfiguredTaskAwaitable.cs
index e68b779..958ef05 100644
--- a/NewLife.Core/Threading/ConfiguredTaskAwaitable.cs
+++ b/NewLife.Core/Threading/ConfiguredTaskAwaitable.cs
@@ -3,6 +3,7 @@ using System.Diagnostics.Contracts;
 using System.Runtime.CompilerServices;
 using System.Threading.Tasks;
 
+#if NET4
 namespace Microsoft.Runtime.CompilerServices
 {
     /// <summary>配置任务await</summary>
@@ -110,4 +111,5 @@ namespace Microsoft.Runtime.CompilerServices
         /// <returns></returns>
         public ConfiguredTaskAwaiter GetAwaiter() { return m_configuredTaskAwaiter; }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +2 -0
diff --git a/NewLife.Core/Threading/ExecutionContextLightup.cs b/NewLife.Core/Threading/ExecutionContextLightup.cs
index 40603ec..c6f82f5 100644
--- a/NewLife.Core/Threading/ExecutionContextLightup.cs
+++ b/NewLife.Core/Threading/ExecutionContextLightup.cs
@@ -1,5 +1,6 @@
 using System;
 
+#if NET4
 namespace System
 {
     internal class ExecutionContextLightup : Lightup
@@ -70,3 +71,4 @@ namespace System
         }
     }
 }
+#endif
\ No newline at end of file
修改 +2 -0
diff --git a/NewLife.Core/Threading/IAsyncMethodBuilder.cs b/NewLife.Core/Threading/IAsyncMethodBuilder.cs
index 15b249c..01e6a18 100644
--- a/NewLife.Core/Threading/IAsyncMethodBuilder.cs
+++ b/NewLife.Core/Threading/IAsyncMethodBuilder.cs
@@ -1,5 +1,6 @@
 using System;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
 	internal interface IAsyncMethodBuilder
@@ -7,3 +8,4 @@ namespace System.Runtime.CompilerServices
 		void PreBoxInitialization();
 	}
 }
+#endif
\ No newline at end of file
修改 +2 -0
diff --git a/NewLife.Core/Threading/IAsyncStateMachine.cs b/NewLife.Core/Threading/IAsyncStateMachine.cs
index 296e7ee..e6280df 100644
--- a/NewLife.Core/Threading/IAsyncStateMachine.cs
+++ b/NewLife.Core/Threading/IAsyncStateMachine.cs
@@ -1,5 +1,6 @@
 using System;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     /// <summary>��ʾΪ�첽�������ɵ�״̬������������������ʹ�á�</summary>
@@ -13,3 +14,4 @@ namespace System.Runtime.CompilerServices
 		void SetStateMachine(IAsyncStateMachine stateMachine);
 	}
 }
+#endif
\ No newline at end of file
修改 +3 -0
diff --git a/NewLife.Core/Threading/ICriticalNotifyCompletion.cs b/NewLife.Core/Threading/ICriticalNotifyCompletion.cs
index f5226ca..b230355 100644
--- a/NewLife.Core/Threading/ICriticalNotifyCompletion.cs
+++ b/NewLife.Core/Threading/ICriticalNotifyCompletion.cs
@@ -1,5 +1,6 @@
 using System;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     /// <summary>��ʾ�Ⱥ������ƻ��ȴ��������ʱ�ĺ������֡�</summary>
@@ -10,3 +11,5 @@ namespace System.Runtime.CompilerServices
 		void UnsafeOnCompleted(Action continuation);
 	}
 }
+
+#endif
\ No newline at end of file
修改 +2 -0
diff --git a/NewLife.Core/Threading/INotifyCompletion.cs b/NewLife.Core/Threading/INotifyCompletion.cs
index 769754b..7d66ee5 100644
--- a/NewLife.Core/Threading/INotifyCompletion.cs
+++ b/NewLife.Core/Threading/INotifyCompletion.cs
@@ -1,5 +1,6 @@
 using System;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
     /// <summary>��ʾ��������ƻ��ȴ��������ʱ�ĺ������֡�</summary>
@@ -10,3 +11,4 @@ namespace System.Runtime.CompilerServices
 		void OnCompleted(Action continuation);
 	}
 }
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/Lightup.cs b/NewLife.Core/Threading/Lightup.cs
index 5f5fa37..9cd9f2e 100644
--- a/NewLife.Core/Threading/Lightup.cs
+++ b/NewLife.Core/Threading/Lightup.cs
@@ -3,6 +3,7 @@ using System.Linq;
 using System.Reflection;
 using System.Threading;
 
+#if NET4
 namespace System
 {
     internal abstract class Lightup
@@ -159,4 +160,5 @@ namespace System
             return null;
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +2 -0
diff --git a/NewLife.Core/Threading/LightupServices.cs b/NewLife.Core/Threading/LightupServices.cs
index aa3d287..e6043ce 100644
--- a/NewLife.Core/Threading/LightupServices.cs
+++ b/NewLife.Core/Threading/LightupServices.cs
@@ -2,6 +2,7 @@ using System;
 using System.Linq;
 using System.Reflection;
 
+#if NET4
 namespace System
 {
     internal static class LightupServices
@@ -56,3 +57,4 @@ namespace System
         }
     }
 }
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/LightupType.cs b/NewLife.Core/Threading/LightupType.cs
index 98a6e4f..3868482 100644
--- a/NewLife.Core/Threading/LightupType.cs
+++ b/NewLife.Core/Threading/LightupType.cs
@@ -1,5 +1,6 @@
 using System;
 
+#if NET4
 namespace System
 {
     internal static class LightupType
@@ -22,4 +23,5 @@ namespace System
             return null;
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/TaskAwaiter.cs b/NewLife.Core/Threading/TaskAwaiter.cs
index cba9394..af182be 100644
--- a/NewLife.Core/Threading/TaskAwaiter.cs
+++ b/NewLife.Core/Threading/TaskAwaiter.cs
@@ -4,6 +4,7 @@ using System.Runtime.CompilerServices;
 using System.Threading;
 using System.Threading.Tasks;
 
+#if NET4
 namespace Microsoft.Runtime.CompilerServices
 {
     /// <summary>表示等待完成的异步任务的对象,并提供结果的参数。</summary>
@@ -190,4 +191,5 @@ namespace Microsoft.Runtime.CompilerServices
             return new AggregateException(exc);
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/TaskEx.cs b/NewLife.Core/Threading/TaskEx.cs
index bca18a1..fa73384 100644
--- a/NewLife.Core/Threading/TaskEx.cs
+++ b/NewLife.Core/Threading/TaskEx.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Diagnostics.Contracts;
 using System.Linq;
 
+#if NET4
 namespace System.Threading.Tasks
 {
     /// <summary>������չ</summary>
@@ -315,4 +316,5 @@ namespace System.Threading.Tasks
             targetList.Add(exception);
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/TimerManager.cs b/NewLife.Core/Threading/TimerManager.cs
index 627e098..f4becd9 100644
--- a/NewLife.Core/Threading/TimerManager.cs
+++ b/NewLife.Core/Threading/TimerManager.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 
+#if NET4
 namespace System.Threading
 {
 	internal static class TimerManager
@@ -23,4 +24,5 @@ namespace System.Threading
 			}
 		}
 	}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/VoidTaskResult.cs b/NewLife.Core/Threading/VoidTaskResult.cs
index ddcd7fd..b864ee9 100644
--- a/NewLife.Core/Threading/VoidTaskResult.cs
+++ b/NewLife.Core/Threading/VoidTaskResult.cs
@@ -1,10 +1,12 @@
 using System;
 using System.Runtime.InteropServices;
 
+#if NET4
 namespace System.Runtime.CompilerServices
 {
 	[StructLayout(LayoutKind.Sequential, Size = 1)]
 	internal struct VoidTaskResult
 	{
 	}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +3 -1
diff --git a/NewLife.Core/Threading/YieldAwaitable.cs b/NewLife.Core/Threading/YieldAwaitable.cs
index 64fc938..2928f2c 100644
--- a/NewLife.Core/Threading/YieldAwaitable.cs
+++ b/NewLife.Core/Threading/YieldAwaitable.cs
@@ -3,6 +3,7 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 
+#if NET4
 namespace Microsoft.Runtime.CompilerServices
 {
     /// <summary>yield</summary>
@@ -43,4 +44,5 @@ namespace Microsoft.Runtime.CompilerServices
             return default(YieldAwaiter);
         }
     }
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
修改 +1 -0
diff --git a/NewLife.Cube/Common/EntityTreeController.cs b/NewLife.Cube/Common/EntityTreeController.cs
index 477899c..3853ce7 100644
--- a/NewLife.Cube/Common/EntityTreeController.cs
+++ b/NewLife.Cube/Common/EntityTreeController.cs
@@ -1,6 +1,7 @@
 using System;
 using System.ComponentModel;
 using System.Linq;
+using System.Reflection;
 using System.Web.Mvc;
 using NewLife.Reflection;
 using NewLife.Web;
修改 +16 -4
diff --git a/NewLife.Cube/NewLife.Cube.csproj b/NewLife.Cube/NewLife.Cube.csproj
index b245fcc..4e47609 100644
--- a/NewLife.Cube/NewLife.Cube.csproj
+++ b/NewLife.Cube/NewLife.Cube.csproj
@@ -13,7 +13,6 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>NewLife.Cube</RootNamespace>
     <AssemblyName>NewLife.Cube</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <MvcBuildViews>false</MvcBuildViews>
     <UseIISExpress>true</UseIISExpress>
     <IISExpressSSLPort />
@@ -28,6 +27,7 @@
     <OldToolsVersion>15.0</OldToolsVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
@@ -38,6 +38,7 @@
     <DocumentationFile>Bin\NewLife.Cube.XML</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>Bin\</OutputPath>
@@ -47,6 +48,17 @@
     <PlatformTarget>AnyCPU</PlatformTarget>
     <DocumentationFile>Bin\NewLife.Cube.XML</DocumentationFile>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <OutputPath>Bin4\</OutputPath>
+    <DefineConstants>TRACE;NET4</DefineConstants>
+    <DocumentationFile>Bin\NewLife.Cube.XML</DocumentationFile>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -671,9 +683,9 @@
   </PropertyGroup>
   <PropertyGroup>
     <PostBuildEvent>
-      md $(ProjectDir)..\..\Bin4
-      copy $(TargetDir)$(TargetName).* $(ProjectDir)..\..\Bin4\ /y
-      del $(ProjectDir)..\..\Bin4\NewLife.Cube.dll.config /q
+      md $(ProjectDir)..\..\Bin
+      copy $(TargetDir)$(TargetName).* $(ProjectDir)..\..\Bin\ /y
+      del $(ProjectDir)..\..\Bin\NewLife.Cube.dll.config /q
     </PostBuildEvent>
   </PropertyGroup>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
修改 +10 -0
diff --git a/NewLife.MQ/NewLife.MQ.csproj b/NewLife.MQ/NewLife.MQ.csproj
index f8b636e..a23c33c 100644
--- a/NewLife.MQ/NewLife.MQ.csproj
+++ b/NewLife.MQ/NewLife.MQ.csproj
@@ -31,6 +31,16 @@
     <WarningLevel>4</WarningLevel>
     <DocumentationFile>..\..\Bin4\NewLife.MQ.XML</DocumentationFile>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
+    <OutputPath>bin\NET4\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <DocumentationFile>..\..\Bin4\NewLife.MQ.XML</DocumentationFile>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core" />
修改 +16 -4
diff --git a/NewLife.Net/NewLife.Net.csproj b/NewLife.Net/NewLife.Net.csproj
index 57011a7..59773e1 100644
--- a/NewLife.Net/NewLife.Net.csproj
+++ b/NewLife.Net/NewLife.Net.csproj
@@ -13,16 +13,27 @@
     <FileAlignment>512</FileAlignment>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\..\Bin4\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <DocumentationFile>..\..\Bin4\NewLife.Net.XML</DocumentationFile>
+    <DocumentationFile>..\..\Bin\NewLife.Net.XML</DocumentationFile>
     <DebugType>full</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <DocumentationFile>..\..\Bin\NewLife.Net.XML</DocumentationFile>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <OutputPath>..\..\Bin4\</OutputPath>
     <DefineConstants>TRACE;NET4</DefineConstants>
@@ -32,6 +43,7 @@
     <DebugType>pdbonly</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
     <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
修改 +2 -1
diff --git a/NewLife.Net/Stress/TcpStressConfig.cs b/NewLife.Net/Stress/TcpStressConfig.cs
index 0fa6469..2e695c1 100644
--- a/NewLife.Net/Stress/TcpStressConfig.cs
+++ b/NewLife.Net/Stress/TcpStressConfig.cs
@@ -1,7 +1,8 @@
 using System;
 using System.ComponentModel;
-using NewLife.Xml;
+using System.Reflection;
 using NewLife.Reflection;
+using NewLife.Xml;
 
 namespace NewLife.Net.Stress
 {
修改 +3 -2
diff --git a/NewLife.Net/UPnP/UPnPAction.cs b/NewLife.Net/UPnP/UPnPAction.cs
index dc4e998..247cfd2 100644
--- a/NewLife.Net/UPnP/UPnPAction.cs
+++ b/NewLife.Net/UPnP/UPnPAction.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Reflection;
 using System.Xml;
 using System.Xml.Serialization;
 using NewLife.Reflection;
@@ -26,7 +27,7 @@ namespace NewLife.Net.UPnP
                 //if (AttributeX.GetCustomAttribute<XmlIgnoreAttribute>(item, true) != null) continue;
 
                 var elmName = item.Name;
-                var att = AttributeX.GetCustomAttribute<XmlElementAttribute>(item, true);
+                var att = item.GetCustomAttribute<XmlElementAttribute>(true);
                 if (att != null && !String.IsNullOrEmpty(att.ElementName)) elmName = att.ElementName;
 
                 var node = doc.SelectSingleNode("//" + elmName);
@@ -72,7 +73,7 @@ namespace NewLife.Net.UPnP
                 //if (AttributeX.GetCustomAttribute<XmlIgnoreAttribute>(item, true) != null) continue;
 
                 var elmName = item.Name;
-                var att = AttributeX.GetCustomAttribute<XmlElementAttribute>(item, true);
+                var att = item.GetCustomAttribute<XmlElementAttribute>(true);
                 if (att != null && !String.IsNullOrEmpty(att.ElementName)) elmName = att.ElementName;
 
                 var elm = doc.CreateElement(elmName);
修改 +31 -31
diff --git a/Test/App.config b/Test/App.config
index 4f18217..3e842b7 100644
--- a/Test/App.config
+++ b/Test/App.config
@@ -1,77 +1,77 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <appSettings>
     <!--是否启用网络调试。默认为不启用-->
-    <add key="NewLife.Net.Debug" value="true" />
+    <add key="NewLife.Net.Debug" value="true"/>
     <!--是否缓存网关。缓存网关可以加速UPnP的发现过程-->
-    <add key="NewLife.Net.UPnP.CacheGateway" value="true" />
+    <add key="NewLife.Net.UPnP.CacheGateway" value="true"/>
 
     <!--日志配置-->
     <!--是否启用全局调试。默认为不启用-->
-    <add key="NewLife.Debug" value="true" />
+    <add key="NewLife.Debug" value="true"/>
     <!--<add key="Debug" value="false"/>-->
     <!--日志目录。默认为当前目录下的Log文件夹-->
-    <add key="NewLife.LogPath" value="" />
+    <add key="NewLife.LogPath" value=""/>
 
     <!--线程池组件配置-->
     <!--是否启用线程池调试。默认为不启用-->
-    <add key="NewLife.Thread.Debug" value="true" />
+    <add key="NewLife.Thread.Debug" value="true"/>
 
     <!--是否启用调试,默认不启用。输出所有执行的SQL语句-->
-    <add key="XCode.Debug" value="true" />
+    <add key="XCode.Debug" value="true"/>
     <!--是否启用缓存调试,默认不启用-->
     <!--<add key="XCode.Cache.Debug" value="true"/>-->
     <!--是否独占数据库,独占时将大大加大缓存权重,默认true(Debug时为false)-->
-    <add key="XCode.Cache.Alone" value="false" />
+    <add key="XCode.Cache.Alone" value="false"/>
     <!--是否启用数据架构,默认不启用。数据架构可以实现通过实体类反向更新数据库结构,不启用时,仅把更新SQL写入日志,如果留空则不做检查-->
-    <add key="XCode.Schema.Enable" value="true" />
+    <add key="XCode.Schema.Enable" value="true"/>
     <!--是否启用不删除字段,默认不启用。删除字段的操作过于危险,这里可以通过设为true关闭-->
-    <add key="XCode.Schema.NoDelete" value="false" />
+    <add key="XCode.Schema.NoDelete" value="false"/>
     <!--要排除的链接名,多个用逗号分隔,默认空。-->
-    <add key="XCode.Schema.Exclude" value="" />
+    <add key="XCode.Schema.Exclude" value=""/>
     <!--连接名映射,把实体类中的Test2和Test3连接名映射到Test去-->
-    <add key="XCode.ConnMaps" value="EntityTest@Common" />
+    <add key="XCode.ConnMaps" value="EntityTest@Common"/>
     <!--是否限制只能访问拥有者的信息,默认false-->
-    <add key="XCode.Oracle.IsUseOwner" value="true" />
+    <add key="XCode.Oracle.IsUseOwner" value="true"/>
     <!--是否启用动态代码调试,把动态生成的实体类代码和程序集输出到临时目录,默认不启用-->
-    <add key="XCode.Code.Debug" value="true" />
+    <add key="XCode.Code.Debug" value="true"/>
 
     <!--模版引擎配置-->
     <!--是否启用调试,默认不启用-->
-    <add key="XTemplate.Debug" value="true" />
+    <add key="XTemplate.Debug" value="true"/>
     <!--模版引用的程序集,多个用逗号或分号隔开-->
-    <add key="XTemplate.References" value="" />
+    <add key="XTemplate.References" value=""/>
     <!--模版引用的命名空间,多个用逗号或分号隔开-->
-    <add key="XTemplate.Imports" value="" />
+    <add key="XTemplate.Imports" value=""/>
     <!--模版基类名-->
-    <add key="XTemplate.BaseClassName" value="" />
+    <add key="XTemplate.BaseClassName" value=""/>
 
     <!--对象容器配置-->
     <!--指定接口在相应注册名称下的实现类型,mode可用于指定是否实例(单例模式)、是否允许覆盖、是否扩展。-->
     <!--<add key="NewLife.ObjectContainer_IA" value="name=a,type=A,mode=singleton|overwrite|extend"/>-->
 
     <!--下载数据库驱动的地址,文件名用{0}替代。默认http://j.NewLifeX.com/?id=3&f={0}-->
-    <add key="XCode.ServiceAddress" value="" />
+    <add key="XCode.ServiceAddress" value=""/>
   </appSettings>
   <connectionStrings>
-    <add name="Common0" connectionString="Data Source=.;Initial Catalog=Common;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
-    <add name="Common1" connectionString="Data Source=.;Initial Catalog=Common2;user id=sa;password=Pass@word" providerName="System.Data.SqlClient" />
-    <add name="Common2" connectionString="Data Source=.;Initial Catalog=wisestate2;user id=sa;password=Pass@word" providerName="System.Data.SqlClient" />
-    <add name="Common" connectionString="Data Source=Common.db;UseLock=false;Default Timeout=0" providerName="Sqlite" />
-    <add name="Common99" connectionString="Data Source=Common99.db;Version=3;" providerName="Sqlite" />
-    <add name="Common4" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=~\AppData\Common.mdb;Persist Security Info=False;" />
-    <add name="Common5" connectionString="Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.34)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORC)));User ID=admin;Password=admin;" providerName="System.Data.OracleClient" />
-    <add name="SqlCe" connectionString="Data Source=Common.sdf;" providerName="SqlCe" />
+    <add name="Common0" connectionString="Data Source=.;Initial Catalog=Common;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
+    <add name="Common1" connectionString="Data Source=.;Initial Catalog=Common2;user id=sa;password=Pass@word" providerName="System.Data.SqlClient"/>
+    <add name="Common2" connectionString="Data Source=.;Initial Catalog=wisestate2;user id=sa;password=Pass@word" providerName="System.Data.SqlClient"/>
+    <add name="Common" connectionString="Data Source=Common.db;UseLock=false;Default Timeout=0" providerName="Sqlite"/>
+    <add name="Common99" connectionString="Data Source=Common99.db;Version=3;" providerName="Sqlite"/>
+    <add name="Common4" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=~\AppData\Common.mdb;Persist Security Info=False;"/>
+    <add name="Common5" connectionString="Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.34)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORC)));User ID=admin;Password=admin;" providerName="System.Data.OracleClient"/>
+    <add name="SqlCe" connectionString="Data Source=Common.sdf;" providerName="SqlCe"/>
   </connectionStrings>
   <runtime>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
-        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
+        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+        <bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0"/>
       </dependentAssembly>
       <dependentAssembly>
-        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
+        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+        <bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0"/>
       </dependentAssembly>
     </assemblyBinding>
   </runtime>
修改 +18 -5
diff --git a/Test/Test.csproj b/Test/Test.csproj
index d4ecf66..e87dd7d 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,27 +11,40 @@
     <RootNamespace>Test</RootNamespace>
     <AssemblyName>Test</AssemblyName>
     <FileAlignment>512</FileAlignment>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <OutputPath>..\..\Test\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <PlatformTarget>AnyCPU</PlatformTarget>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>..\..\Test\</OutputPath>
-    <DefineConstants>TRACE;NET4</DefineConstants>
+    <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <PlatformTarget>AnyCPU</PlatformTarget>
     <UseVSHostingProcess>true</UseVSHostingProcess>
     <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>..\..\Test4\</OutputPath>
+    <DefineConstants>TRACE;NET4</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
修改 +17 -0
diff --git "a/X\347\273\204\344\273\266.sln" "b/X\347\273\204\344\273\266.sln"
index 8e222a1..721383a 100644
--- "a/X\347\273\204\344\273\266.sln"
+++ "b/X\347\273\204\344\273\266.sln"
@@ -22,39 +22,56 @@ EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
+		NET4|Any CPU = NET4|Any CPU
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{3EB3A5F1-F785-4672-A21D-A3117FC12129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{3EB3A5F1-F785-4672-A21D-A3117FC12129}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3EB3A5F1-F785-4672-A21D-A3117FC12129}.NET4|Any CPU.ActiveCfg = Release|Any CPU
+		{3EB3A5F1-F785-4672-A21D-A3117FC12129}.NET4|Any CPU.Build.0 = Release|Any CPU
 		{3EB3A5F1-F785-4672-A21D-A3117FC12129}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{3EB3A5F1-F785-4672-A21D-A3117FC12129}.Release|Any CPU.Build.0 = Release|Any CPU
 		{6740B4CD-B2F6-49DF-BDA0-7DC17144C666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{6740B4CD-B2F6-49DF-BDA0-7DC17144C666}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6740B4CD-B2F6-49DF-BDA0-7DC17144C666}.NET4|Any CPU.ActiveCfg = Release|Any CPU
+		{6740B4CD-B2F6-49DF-BDA0-7DC17144C666}.NET4|Any CPU.Build.0 = Release|Any CPU
 		{6740B4CD-B2F6-49DF-BDA0-7DC17144C666}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{6740B4CD-B2F6-49DF-BDA0-7DC17144C666}.Release|Any CPU.Build.0 = Release|Any CPU
 		{B49ABA5A-C5DA-45F4-87F1-B435EC51D710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{B49ABA5A-C5DA-45F4-87F1-B435EC51D710}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{B49ABA5A-C5DA-45F4-87F1-B435EC51D710}.NET4|Any CPU.ActiveCfg = NET4|Any CPU
+		{B49ABA5A-C5DA-45F4-87F1-B435EC51D710}.NET4|Any CPU.Build.0 = NET4|Any CPU
 		{B49ABA5A-C5DA-45F4-87F1-B435EC51D710}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{B49ABA5A-C5DA-45F4-87F1-B435EC51D710}.Release|Any CPU.Build.0 = Release|Any CPU
 		{55BA37EE-01A2-438F-A0FB-6B57440BF2F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{55BA37EE-01A2-438F-A0FB-6B57440BF2F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{55BA37EE-01A2-438F-A0FB-6B57440BF2F0}.NET4|Any CPU.ActiveCfg = NET4|Any CPU
+		{55BA37EE-01A2-438F-A0FB-6B57440BF2F0}.NET4|Any CPU.Build.0 = NET4|Any CPU
 		{55BA37EE-01A2-438F-A0FB-6B57440BF2F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{55BA37EE-01A2-438F-A0FB-6B57440BF2F0}.Release|Any CPU.Build.0 = Release|Any CPU
 		{5813C22E-EEB3-4DEE-A45C-BB218041193A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{5813C22E-EEB3-4DEE-A45C-BB218041193A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5813C22E-EEB3-4DEE-A45C-BB218041193A}.NET4|Any CPU.ActiveCfg = NET4|Any CPU
+		{5813C22E-EEB3-4DEE-A45C-BB218041193A}.NET4|Any CPU.Build.0 = NET4|Any CPU
 		{5813C22E-EEB3-4DEE-A45C-BB218041193A}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{5813C22E-EEB3-4DEE-A45C-BB218041193A}.Release|Any CPU.Build.0 = Release|Any CPU
 		{5A8EF50C-3394-4C1E-99F0-33EFE8691CB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{5A8EF50C-3394-4C1E-99F0-33EFE8691CB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5A8EF50C-3394-4C1E-99F0-33EFE8691CB0}.NET4|Any CPU.ActiveCfg = NET4|Any CPU
+		{5A8EF50C-3394-4C1E-99F0-33EFE8691CB0}.NET4|Any CPU.Build.0 = NET4|Any CPU
 		{5A8EF50C-3394-4C1E-99F0-33EFE8691CB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{5A8EF50C-3394-4C1E-99F0-33EFE8691CB0}.Release|Any CPU.Build.0 = Release|Any CPU
 		{7AC0E99B-CFD8-4B59-8838-503EAA30523F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{7AC0E99B-CFD8-4B59-8838-503EAA30523F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{7AC0E99B-CFD8-4B59-8838-503EAA30523F}.NET4|Any CPU.ActiveCfg = NET4|Any CPU
+		{7AC0E99B-CFD8-4B59-8838-503EAA30523F}.NET4|Any CPU.Build.0 = NET4|Any CPU
 		{7AC0E99B-CFD8-4B59-8838-503EAA30523F}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{7AC0E99B-CFD8-4B59-8838-503EAA30523F}.Release|Any CPU.Build.0 = Release|Any CPU
 		{D32ADD53-5267-479D-96B7-B987E032E010}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{D32ADD53-5267-479D-96B7-B987E032E010}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D32ADD53-5267-479D-96B7-B987E032E010}.NET4|Any CPU.ActiveCfg = NET4|Any CPU
+		{D32ADD53-5267-479D-96B7-B987E032E010}.NET4|Any CPU.Build.0 = NET4|Any CPU
 		{D32ADD53-5267-479D-96B7-B987E032E010}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{D32ADD53-5267-479D-96B7-B987E032E010}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
修改 +4 -2
diff --git a/XCode/Configuration/TableItem.cs b/XCode/Configuration/TableItem.cs
index 29f5b4c..1f3cb89 100644
--- a/XCode/Configuration/TableItem.cs
+++ b/XCode/Configuration/TableItem.cs
@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Linq;
+using System.Reflection;
+using System.Reflection;
 using System.Xml.Serialization;
 using NewLife.Collections;
 using NewLife.Configuration;
@@ -217,8 +219,8 @@ namespace XCode.Configuration
             _Table = type.GetCustomAttribute<BindTableAttribute>(true);
             if (_Table == null) throw new ArgumentOutOfRangeException("type", "类型" + type + "没有" + typeof(BindTableAttribute).Name + "特性!");
 
-            _Indexes = type.GetCustomAttributes<BindIndexAttribute>(true);
-            _Relations = type.GetCustomAttributes<BindRelationAttribute>(true);
+            _Indexes = type.GetCustomAttributes<BindIndexAttribute>(true).ToArray();
+            _Relations = type.GetCustomAttributes<BindRelationAttribute>(true).ToArray();
             _Description = type.GetCustomAttribute<DescriptionAttribute>(true);
             _ModelCheckMode = type.GetCustomAttribute<ModelCheckModeAttribute>(true);
 
修改 +0 -7
diff --git a/XCode/DataAccessLayer/Database/Access.cs b/XCode/DataAccessLayer/Database/Access.cs
index 6d69e7a..6a09fcf 100644
--- a/XCode/DataAccessLayer/Database/Access.cs
+++ b/XCode/DataAccessLayer/Database/Access.cs
@@ -14,12 +14,10 @@ using NewLife.Reflection;
 using ADODB;
 using ADOX;
 using DAO;
-#if NET4
 using ConnectionClass = ADODB.Connection;
 using DBEngineClass = DAO.DBEngine;
 using CatalogClass = ADOX.Catalog;
 #endif
-#endif
 
 namespace XCode.DataAccessLayer
 {
@@ -38,11 +36,6 @@ namespace XCode.DataAccessLayer
                 if (_dbProviderFactory == null)
                 {
                     _dbProviderFactory = OleDbFactory.Instance;
-
-                    // 检查ADOX
-#if !NET4
-                    //CheckAndDownload("Interop.ADOX.dll");
-#endif
                 }
                 return _dbProviderFactory;
             }
修改 +0 -115
diff --git a/XCode/DataAccessLayer/Database/SQLite.cs b/XCode/DataAccessLayer/Database/SQLite.cs
index 3faad17..a53715f 100644
--- a/XCode/DataAccessLayer/Database/SQLite.cs
+++ b/XCode/DataAccessLayer/Database/SQLite.cs
@@ -241,14 +241,6 @@ namespace XCode.DataAccessLayer
         /// <returns></returns>
         public override String StringConcat(String left, String right) { return (!String.IsNullOrEmpty(left) ? left : "\'\'") + "||" + (!String.IsNullOrEmpty(right) ? right : "\'\'"); }
         #endregion
-
-        #region 读写锁
-        //#if NET4
-        //        public ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim();
-        //#else
-        //        public ReaderWriterLock rwLock = new ReaderWriterLock();
-        //#endif
-        #endregion
     }
 
     /// <summary>SQLite数据库</summary>
@@ -284,94 +276,6 @@ namespace XCode.DataAccessLayer
         #endregion
 
         #region 基本方法 查询/执行
-        ///// <summary>文件锁定重试次数</summary>
-        //const Int32 RetryTimes = 5;
-
-        //TResult TryWrite<TArg, TResult>(Func<TArg, TResult> func, TArg arg)
-        //{
-        //    //            var db = Database as SQLite;
-        //    //            // 支持使用锁来控制SQLite并发
-        //    //            // 必须锁数据库对象,因为一个数据库可能有多个数据会话
-        //    //            if (db.UseLock)
-        //    //            {
-        //    //                var rwLock = db.rwLock;
-        //    //#if NET4
-        //    //                rwLock.EnterWriteLock();
-        //    //#else
-        //    //                rwLock.AcquireWriterLock(30000);
-        //    //#endif
-        //    //                try
-        //    //                {
-        //    //                    return func(arg);
-        //    //                }
-        //    //                finally
-        //    //                {
-        //    //#if NET4
-        //    //                    rwLock.ExitWriteLock();
-        //    //#else
-        //    //                    rwLock.ReleaseWriterLock();
-        //    //#endif
-        //    //                }
-        //    //            }
-
-        //    return func(arg);
-
-        //    ////! 如果异常是文件锁定,则重试
-        //    //for (int i = 0; i < RetryTimes; i++)
-        //    //{
-        //    //    try
-        //    //    {
-        //    //        return func(arg);
-        //    //    }
-        //    //    catch (Exception ex)
-        //    //    {
-        //    //        if (i >= RetryTimes - 1) throw;
-
-        //    //        if (ex.Message.Contains("is locked"))
-        //    //        {
-        //    //            Thread.Sleep(300);
-        //    //            continue;
-        //    //        }
-
-        //    //        throw;
-        //    //    }
-        //    //}
-        //    //return default(TResult);
-        //}
-
-        //        TResult TryRead<TArg, TResult>(Func<TArg, TResult> func, TArg arg)
-        //        {
-        //            var db = Database as SQLite;
-        //            // 支持使用锁来控制SQLite并发
-        //            if (!db.UseLock) return func(arg);
-
-        //            var rwLock = db.rwLock;
-        //#if NET4
-        //            rwLock.EnterReadLock();
-        //#else
-        //            rwLock.AcquireReaderLock(30000);
-        //#endif
-        //            try
-        //            {
-        //                return func(arg);
-        //            }
-        //            finally
-        //            {
-        //#if NET4
-        //                rwLock.ExitReadLock();
-        //#else
-        //                rwLock.ReleaseReaderLock();
-        //#endif
-        //            }
-        //        }
-
-        //public override int BeginTransaction() { return TryWrite<Object, Int32>(s => base.BeginTransaction(), null); }
-
-        ///// <summary>已重载。增加锁</summary>
-        ///// <param name="cmd"></param>
-        ///// <returns></returns>
-        //public override Int32 Execute(DbCommand cmd) { return TryWrite<DbCommand, Int32>(base.Execute, cmd); }
-
         /// <summary>执行插入语句并返回新增行的自动编号</summary>
         /// <param name="sql">SQL语句</param>
         /// <param name="type">命令类型,默认SQL文本</param>
@@ -379,27 +283,8 @@ namespace XCode.DataAccessLayer
         /// <returns>新增行的自动编号</returns>
         public override Int64 InsertAndGetIdentity(string sql, CommandType type = CommandType.Text, params DbParameter[] ps)
         {
-            //return TryWrite<String, Int64>(delegate(String sql2)
-            //{
-            //    return ExecuteScalar<Int64>(sql2 + ";Select last_insert_rowid() newid", type, ps);
-            //}, sql);
             return ExecuteScalar<Int64>(sql + ";Select last_insert_rowid() newid", type, ps);
         }
-
-        //public override DataSet Query(DbCommand cmd) { return TryRead<DbCommand, DataSet>(base.Query, cmd); }
-
-        //protected override T ExecuteScalar<T>(DbCommand cmd)
-        //{
-        //    return TryRead<DbCommand, T>(base.ExecuteScalar<T>, cmd);
-        //}
-
-        //public override DbCommand CreateCommand()
-        //{
-        //    var cmd = base.CreateCommand();
-        //    // SQLite驱动内部的SQLite3.Step会等待指定秒数
-        //    cmd.CommandTimeout = 15;
-        //    return cmd;
-        //}
         #endregion
 
         #region 高级
修改 +1 -4
diff --git a/XCode/Entity/Entity.cs b/XCode/Entity/Entity.cs
index fdfdaa9..350be13 100644
--- a/XCode/Entity/Entity.cs
+++ b/XCode/Entity/Entity.cs
@@ -1409,12 +1409,9 @@ namespace XCode
         //[Obsolete("该成员在后续版本中将不再被支持!")]
         public static TEntity FromJson(String json)
         {
-#if NET4
             //return JsonHelper.ToJsonEntity<TEntity>(json);
             return json.ToJsonEntity<TEntity>();
-#else
-            return new Json().Deserialize<TEntity>(json);
-#endif
+            //return new Json().Deserialize<TEntity>(json);
         }
         #endregion
 
修改 +1 -0
diff --git a/XCode/Entity/EntityFactory.cs b/XCode/Entity/EntityFactory.cs
index df44e3c..da1895b 100644
--- a/XCode/Entity/EntityFactory.cs
+++ b/XCode/Entity/EntityFactory.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 using NewLife.Collections;
 using NewLife.Log;
 using NewLife.Reflection;
修改 +1 -0
diff --git a/XCode/Entity/EntitySession.cs b/XCode/Entity/EntitySession.cs
index b673ca3..0694412 100644
--- a/XCode/Entity/EntitySession.cs
+++ b/XCode/Entity/EntitySession.cs
@@ -3,6 +3,7 @@ using System.ComponentModel;
 using System.Data;
 using System.Data.Common;
 using System.Diagnostics;
+using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Text;
 using System.Threading;
修改 +15 -4
diff --git a/XCode/XCode.csproj b/XCode/XCode.csproj
index e997b20..5754160 100644
--- a/XCode/XCode.csproj
+++ b/XCode/XCode.csproj
@@ -11,18 +11,28 @@
     <RootNamespace>XCode</RootNamespace>
     <AssemblyName>XCode</AssemblyName>
     <SignAssembly>false</SignAssembly>
-    <TargetFrameworkProfile />
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\..\Bin4\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <DocumentationFile>..\..\Bin4\XCode.XML</DocumentationFile>
     <DebugType>full</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <DocumentationFile>..\..\Bin4\XCode.XML</DocumentationFile>
+    <Optimize>true</Optimize>
+    <WarningLevel>2</WarningLevel>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <OutputPath>..\..\Bin4\</OutputPath>
     <DefineConstants>TRACE;NET4</DefineConstants>
     <DocumentationFile>..\..\Bin4\XCode.XML</DocumentationFile>
@@ -30,6 +40,7 @@
     <WarningLevel>2</WarningLevel>
     <DebugType>pdbonly</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="Microsoft.CSharp" />
修改 +13 -4
diff --git a/XCoder/XCoder.csproj b/XCoder/XCoder.csproj
index f523e60..5b79325 100644
--- a/XCoder/XCoder.csproj
+++ b/XCoder/XCoder.csproj
@@ -13,17 +13,17 @@
     <ApplicationIcon>leaf.ico</ApplicationIcon>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
     <OutputPath>..\..\XCoder\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
     <DebugType>full</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
     <OutputPath>..\..\XCoder\</OutputPath>
-    <DefineConstants>TRACE;NET4</DefineConstants>
+    <DefineConstants>TRACE</DefineConstants>
     <Optimize>true</Optimize>
     <DebugType>pdbonly</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -31,6 +31,15 @@
   <PropertyGroup>
     <ApplicationManifest>app.manifest</ApplicationManifest>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <OutputPath>..\..\XCoder\</OutputPath>
+    <DefineConstants>TRACE;NET4</DefineConstants>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.configuration" />
修改 +0 -1
diff --git a/XTemplate/Templating/TemplateItem.cs b/XTemplate/Templating/TemplateItem.cs
index 72c5cea..bbb225c 100644
--- a/XTemplate/Templating/TemplateItem.cs
+++ b/XTemplate/Templating/TemplateItem.cs
@@ -31,7 +31,6 @@ namespace XTemplate.Templating
             set { _ClassName = value; }
         }
 
-        private String _BaseClassName;
         /// <summary>模版头指令指定的基类名。如果为空表示没有指令指定基类</summary>
         public String BaseClassName { get; set; }
 
修改 +14 -4
diff --git a/XTemplate/XTemplate.csproj b/XTemplate/XTemplate.csproj
index befe9bf..eb8cd99 100644
--- a/XTemplate/XTemplate.csproj
+++ b/XTemplate/XTemplate.csproj
@@ -14,15 +14,24 @@
     <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <DebugSymbols>true</DebugSymbols>
-    <OutputPath>..\..\Bin4\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
-    <DocumentationFile>..\..\Bin4\XTemplate.XML</DocumentationFile>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
+    <DocumentationFile>..\..\Bin\XTemplate.XML</DocumentationFile>
     <DebugType>full</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <OutputPath>..\..\Bin\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <DocumentationFile>..\..\Bin\XTemplate.XML</DocumentationFile>
+    <Optimize>true</Optimize>
+    <DebugType>pdbonly</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'NET4|AnyCPU'">
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <OutputPath>..\..\Bin4\</OutputPath>
     <DefineConstants>TRACE;NET4</DefineConstants>
@@ -30,6 +39,7 @@
     <Optimize>true</Optimize>
     <DebugType>pdbonly</DebugType>
     <PlatformTarget>AnyCPU</PlatformTarget>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />