0

Building a .NET library and want to target .NET Standard 1.1 for compatibility. I have it building and something basic running, but I can't figure out how to write to the console(!). Trying to use System.Console.Write gives an error:

error CS0234: The type or namespace name 'Console' does not exist in the namespace 'System' (are you missing an assembly reference?)

I have using System and the code works fine if I target .NET Standard 1.3 or later.

.NET Standard 1.1 does have the ability to write to the console, right?!

codesniffer
  • 733
  • 5
  • 15
  • Indeed it is there: https://docs.microsoft.com/en-us/dotnet/api/system.console.writeline?view=netframework-4.7.2#applies-to So the message is propably right and you are msising assembly? You need "System.Console.dll, mscorlib.dll, netstandard.dll" It could also be that you are targetting the much newer .NET Core 1.1, wich might have different names/Functions – Christopher Nov 04 '18 at 00:40
  • 1
    However, I would advise to never use 1.1 For compabiltiy anything short of 3 or 3.5 seems excessive. What is that suppsoed to run on, Windows XP SP 3? https://en.wikipedia.org/wiki/.NET_Framework#Release_history 1.1 did not even have the Invoke prorection. Or TryParse for that mater. If you need that much backwards compatibiltiy, you are propably better off just taking native C++ and not requiring .NET to begin with. – Christopher Nov 04 '18 at 00:43
  • 1
    @Christopher Is is possible that you are confusing `.NET Framework 1.1` with `.NET Standard 1.1`? They're very different. – spender Nov 04 '18 at 01:09
  • According to https://docs.microsoft.com/en-us/dotnet/api/system.console.writeline?view=netframework-4.7.2#applies-to Console.WriteLine started in .NET Standard 1.3. And it works if I change to target that version, so I'm confident this is related to some difference in the versions. – codesniffer Nov 04 '18 at 05:37
  • @Christopher It's clear in the configuration that I'm targeting .NET Standard 1.1, not .NET Core. I'm targeting .NET Standard 1.1 for Windows Server 2003 (customer requirement). – codesniffer Nov 04 '18 at 05:52
  • See https://stackoverflow.com/questions/36516768/console-write-in-net-core/36516933 or like written there you need to NuGet https://www.nuget.org/packages/System.Console/ – ckuri Nov 04 '18 at 12:02
  • @codesniffer: Then make certain you actually have those asembly references added. They are only added automatically to a Console Project. If you started this as any other form of Project, they are not auto-added. – Christopher Nov 04 '18 at 17:17
  • @spender: Not impossible, but I am pretty sure .NET 1.1 had both those Limitations. https://stackoverflow.com/a/14703806/3346583 Actually TryParse was even only added with 2.0: https://docs.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=netframework-4.7.2#applies-to – Christopher Nov 04 '18 at 17:19
  • @Christopher The project was created as a C# Class Library (.NET Standard). Since the code works as-is if I simply change the Target Framework to .NET Standard 1.3, doesn't that mean all necessary references are already present? Incidentally, I don't see an option to add any assembly references to this project (screenshot at https://imgur.com/a/hNwKKwi). – codesniffer Nov 05 '18 at 16:11
  • @codesniffer Should != is If you started it as a Console project, the assembly references should be there. But evidently they are not. – Christopher Nov 06 '18 at 04:16

0 Answers0