title: Upgrade TargetFramework for C++ project
body: <p>I have changed target framework from <code>&lt;TargetFrameworkVersion&gt;v4.5.2&lt;/TargetFrameworkVersion&gt;</code> to <code>&lt;TargetFrameworkVersion&gt;v4.8&lt;/TargetFrameworkVersion&gt;</code> for a C++ project.
  And now I'm getting an exception:</p>
  <blockquote>
  <p>Exception thrown: 'System.Configuration.ConfigurationErrorsException'
  in System.Configuration.dll log4net:ERROR Exception while reading
  ConfigurationSettings. Check your .config file is well formed XML.</p>
  <p>System.Configuration.ConfigurationErrorsException: Configuration
  system failed to initialize ---&gt; System.TypeInitializationException:
  The type initializer for 'System.Uri' threw an exception. ---&gt;
  System.TypeInitializationException: The type initializer for
  'System.UriParser' threw an exception. ---&gt;
  System.TypeInitializationException: The type initializer for
  'System.Runtime.Versioning.BinaryCompatibility' threw an exception.
  ---&gt; System.ArgumentException: String cannot be of zero length. Parameter name: frameworkName    at
  System.Runtime.Versioning.BinaryCompatibility.ParseFrameworkName(String
  frameworkName, String&amp; identifier, Int32&amp; version, String&amp; profile)<br />
  at
  System.Runtime.Versioning.BinaryCompatibility.ParseTargetFrameworkMonikerIntoEnum(String
  targetFrameworkMoniker, TargetFrameworkId&amp; targetFramework, Int32&amp;
  targetFrameworkVersion)    at
  System.Runtime.Versioning.BinaryCompatibility.ReadTargetFrameworkId()
  at
  System.Runtime.Versioning.BinaryCompatibility.get_AppWasBuiltForFramework()
  at System.Runtime.Versioning.BinaryCompatibility..cctor()    --- End
  of inner exception stack trace ---    at System.UriParser..cctor()<br />
  --- End of inner exception stack trace ---    at System.Uri..cctor()    --- End of inner exception stack trace ---    at System.Configuration.ClientConfigurationSystem..ctor()    at
  System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
  --- End of inner exception stack trace ---    at System.Configuration.ConfigurationManager.PrepareConfigSystem()    at
  System.Configuration.ConfigurationManager.get_AppSettings()    at
  log4net.Util.SystemInfo.GetAppSetting(String key)</p>
  </blockquote>
  <p>My investigation gives me the reason: while compilation VS2015 adds <code>[assembly: TargetFramework(&quot;&quot;, FrameworkDisplayName = &quot;&quot;)]</code>. That's why I can't add the correct <code>TargetFrameworkAttribute</code> manually. And this automatically added attribute causes an exception as the target framework can't be an empty string.</p>
  <p>Do you have any advice, on how could I fix this problem?</p>
  <p><strong>Update:</strong>
  Well, I've enabled logging as Hans Passant said. But I had no luck. As there was no word about .Net 4.0 and Visual Studio created  correct file <code>%temp%\.NETFramework,Version=v4.8.AssemblyAttributes.cpp</code>, but the content of the file:</p>
  <blockquote>
  <p>#using &lt;mscorlib.dll&gt; [assembly: System::Runtime::Versioning::TargetFrameworkAttribute(L&quot;&quot;,
  FrameworkDisplayName=L&quot;&quot;)];</p>
  </blockquote>
  <p>Nevertheless, I found a hack - I'm adding the required attribute manually.
  To do it I defined a variable in the project file:</p>
  <pre><code> &lt;GenerateTargetFrameworkAttribute&gt;false&lt;/GenerateTargetFrameworkAttribute&gt;
  </code></pre>
  <p>This variable avoids the automatic creation of the <code>TargetFrameworkAttribute</code>. So I can add the correct attribute from my code:</p>
  <pre><code>[assembly:TargetFramework(&quot;.NETFramework,Version=v4.8&quot;, FrameworkDisplayName = &quot;.NET Framework 4.8&quot;)];
  </code></pre>
  <p>With this workaround, I can start the application and it seems to work everything... but I do not really like it.</p>