Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, December 1, 2017 12:56 PM
When I build my App targeting .NET 3.5, I get the following warning:
2> Rebuild All started: Project: MyApp, Configuration: Legacy x64
2>CSC : warning CS8012: Referenced assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' targets a different processor.
When I target .NET 4.6, I don't get this warning. Can someone please tell me what is going on ? Is the warning serious enough to break the App ?
.NET 4.6 is targeted by setting the the VS2017 Project Properties.
.NET 3.5 is targeted by manually adding <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> to the .csproj file.
The targeting is done this way because I need to build against both targets, and VS IDE only allows one.
All replies (3)
Monday, December 4, 2017 5:50 AM âś…Answered | 1 vote
Hi Dev10110110,
>>When I target .NET 4.6, I don't get this warning. Can someone please tell me what is going on ? Is the warning serious enough to break the App ?
Based on your description and I create a simple demo and reproduce your issue on my side, This is a normal warning, you will always get it when you explicitly target x64. It won't be a problem at runtime because on a 64-bit machine, the GAC stores a 64-bit specific version of system.web.dll.****
And the issue was solved in .NET 4.0 and later version.
Best regards,
Zhanglong Wu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Friday, December 1, 2017 1:26 PM
Here's additional information:
using System.Windows.Forms;
using System.Web;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1 ()
{
InitializeComponent();
MessageBox.Show ( HttpUtility.UrlEncode ("abc") );
}
}
}
Building this against AnyCPU and x64 targeting .NET 3.5 results in the warning.
Building this against x86 targeting .NET 3.5 produces no warning.
Building this against AnyCPU, x86, and x64 targeting .NET 4.6 produces no warning.
Friday, December 1, 2017 2:00 PM
Hello,
See the following
https://blogs.msmvps.com/punitganshani/2015/06/21/5-steps-to-targeting-multiple-net-frameworks/
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator