We've recently received a project that was started using Visual Studio 2015. In the code there were places where developers used
null conditional member access
operator. We are using Visual Studio 2013 and the code does not compile I've read the documentation from msdn (https://msdn.microsoft.com/en-us/library/6a71f45d(v=vs.140).aspx) and it states that this operator is not available with Visual Studio 2013. What's the logic behind this decision? The c# syntax depends on IDE? Shouldn't this be fixed for the same .net version?
This is simply a matter of what is available to use with different versions of C# and VS.
This is not a bug. Clearly that solution is making use of the latest tooling and version c# available, you are not. The same applies if you where only using .net 2.0, you wouldn't be able to use Linq. Thus you have to accommodate it in some way
With VS 2013, it comes with .net 4.5.1 and C# 5, you can
Either install .net framework 4.6 and C#6 , then just update the targeted framework version in your projects
or use VS2015, then just update the targeted framework version in your projects
or laboriously reverse that syntax sugar back like the following:
someObject?.PossiblySafeProperty?.LessSafeNestedProperty
//to
string valueYouWant = null;
if(someObject != null && someObject.PossiblySafeProperty!=null)
{
valueYouWant = someObject.PossiblySafeProperty.LessSafeNestedProperty;
}
As far as what the IDE can interpret yes, C# 6 syntax is only available in VS2015. However, using the latest compiler will fix your build errors(albeit not showing up correct in the IDE). And the .Net version has nothing to do with the languages syntax, only the libraries you can use in it. The logic behind the decision? To get you to upgrade to a newer product, same as offering Windows 10 for free. Microsoft wants you using the "latest and greatest" they have to offer.
Related
I create a solution with 4 projects. One of them VSIX project, the other is Project Template and 2 of them are Item template. I want to create VSIX because all team use it. Exporting directly item template from visual studio working fine, but it is not good solution for team-works.
I use C# 10 version at my project. I want to create this template to targeting C# 10 language version. However in list there is only .NET Framework 4.8. So in this case, I cannot use record type or other new things.
How can I create a Visual Studio extension for .NET 6? How I target that or is there another way?
I use Visual Studio 2022.
Visual Studio 2022 targets .NET Framework, so you cannot write a VSIX targeting .NET 6 and have it install into VS2022.
That said, if you want to use newer C# features in .NET Framework projects, you can create an SDK-style project and manually change the .csproj file to have TargetFramework net472 and set LangVersion to 10 or whatever you prefer. While this works, it's not a scenario that Microsoft supports.
Note that for VSIX projects this is currently a bit tricky to get working. An example can be found here, however that's quite a complex build so it will require a good level of familiarity with MSBuild to use it as a reference.
Once you have increase the language version, you will also need something like https://www.nuget.org/packages/IsExternalInit to make record types compile correctly for .NET Framework.
I have a .Net standard 2.0 project in a Visual Studio solution that contains some Azure functions. In the same solution, I've created a .Net Core 2.0 Unit Test project. I've added a project reference from the .Net Core Unit Test project to the .Net standard 2.0 library.
Despite the project reference, Visual Studio is behaving like I'm referencing a dll instead of the project. For example, if I try to use F12/Go to reference, it brings me to a 'From metadata' file instead of the actual code file in the other project. Additionally, codelens features like 'Tested by' (and even just 'referenced by') and the Live Unit testing icons in the .Net Standard project aren't working, since they don't seem to be aware of the Unit Test project at all.
Is there some way to get this integration working between the two projects? My Visual Studio is up to date (15.5.3 enterprise), and I'm not using any tools like Resharper or anything like that.
I'm also facing the same issue but so far the project reference vs dll reference is not the case. I believe this is an existing issue with Azure function projects. There is a thread in Microsoft community regarding this issue. The last comment from Visual Studio is as follows:
I'm closing this report, because in the last 90 days there was no internal developer activity and very small number of new votes or comments. Sorry, we would like to look at this further, but we just don’t have the time right now. Our goal in closing older issues such as this one is to keep customers informed on which issues are currently being pursued by Visual Studio teams. If you still have trouble with our latest version, please report it as a new problem.
I'm confused. We upgraded our project recently to .NET 4.5.1. We installed .NET 4.5.1 on our servers.
I'm referencing assembly System.Threading.Tasks.Dataflow from the GAC at C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Threading.Tasks.Dataflow\v4.0_4.5.9.0__b03f5f7f11d50a3a\System.Threading.Tasks.Dataflow.dll
CopyLocal is set to false as (I assume) it's part of the Framework, so should be already installed wherever the app is deployed.
The trouble is, when running on the server, it says it can't find this assembly.
I've read here that is is part of .NET Framework 4.5:
but the library is now built-in with .NET 4.5.
...and I've read here that it isn't!
The TPL Dataflow Library (System.Threading.Tasks.Dataflow namespace) is not distributed with the .NET Framework 4.5
What gives? It doesn't look like it is. Is it just part of the 'targetting pack'? Is it me, or are these in-place upgrades more agro than they're worth?!
I'm not sure why that page says it is part of .NET 4.5 -- it's still an out-of-band NuGet release, like Entity Framework, MVC, etc.
I recognize this question is pretty old, but I wanted to add my solution as well. I found adding the below two items to the Visual Studio 2019 install (run Visual Studio Installer > Modify > .Net Desktop Development) the problem went away and it was able to pull System.Threading.Tasks.Dataflow from the GAC.
Edit: Installing Visual Studio 2015 also seemed to be required. Obviously it isn't VS 2015 itself, just something it comes with. But there are too many packages for me to figure out which one easily.
Edit2: This isn't really the best solution, more of a stopgap. MS suggests downloading it through Nuget. https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow?view=netcore-3.1
The TPL Dataflow Library (the System.Threading.Tasks.Dataflow namespace) is not distributed with .NET. To install the System.Threading.Tasks.Dataflow namespace in Visual Studio, open your project, choose Manage NuGet Packages from the Project menu...
I rebuilt F# with few syntax additions. I was able to tell VS2010 to use them for F# Interactive and for building, but the code editor still claims I'm making errors (even though the project builds just fine).
Is it even possible to change this? If it is - how?
As far as I know, there is no way to change the IntelliSense service used by F# in Visual Studio. The Visual Studio component isn't a part of the open-source release and it has a reference to strongly-signed FSharp.Compiler.dll. I'm not sure if there is some way to trick .NET to load a different assembly instead (specifying bindingRedirect in app.config requires the same strong name). If you find some way, let me know :-) I'd like to use it with my modified version of F# too.
If you want to get some IntelliSense for your modified F#, you can use the F# MonoDevelop plugin. The plugin is open-source and you can change the F# version used in the Services/FSharpCompiler.fs file (see the source on GitHub).
Duplicate: Why are C# collection-properties not flagged as obsolete when calling properties on them?
I just migrated a .NET 1.1 project to .NET 2.0 using Visual Studio 2008. I know that there are references to obsolete methods in the project.
But Visual Studio does not show "obsolete"-warnings after building. The build succeeds and shows only 3 warnings from members that are assigned a value that is never used. When I remove these members there are no warnings at all.
I NEED THESE "OBSOLETE"-WARNINGS
The Warning level is 4 (maximum), Warnings are enabled.
Just one sample:
protected internal DataConnector()
{
_connectionString = ConfigurationSettings.AppSettings["ProductConnectionString"];
}
All references that should result in an "obsolete"-warning are to members of classes of the .NET Framework.
Is the code calling the obsolete method(s) itself flagged as obsolete?
Just taking a shot in the dark here, but is the usage of an obsolete member taking place in a project that you're REFERENCING, and when you're building it isn't actually rebuilding that project? If that's a possibility, I would try manually building the project where the usage is taking place, or just rebuilding the entire solution.
Make sure you are doing a full build on the project, not just an incremental build.
Jeff Yates is right, this is a duplicate to Why are C# collection-properties not flagged as obsolete when calling properties on them?
It is a bug in the C# 3.5 compiler reported here:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=417159
I checked it: copied the csc.exe commandline from the output window to a cmd-console. When I change the directory to the .NET 2.0 directory (using C# 2.0 compiler), it shows the warnings. Microsoft knows this bug and fixed it in C# 4.0 but will not fix it in the 3.5 version.