Oleksandr Ragoza
New member
- Joined
- Jul 20, 2022
- Messages
- 2
- Programming Experience
- Beginner
I'm trying to follow one of the tutorial for Xamarin application. My VS is: Microsoft Visual Studio Community 2019 Version 16.11.17 VisualStudio.16.Release/16.11.5+31729.503 Microsoft .NET Framework Version 4.8.04084
The stucture of my Xamarin solution is:
GalleryApp
Models
IPhotoImporter
GalleryApp.Android
GalleryApp.IOS
PhotoImporter : IPhotoImporter
After a while, I've reached the chapter, which produces the following code (in iOS project in PhotoImporter class):
this code [startIndex..endIndex] throws an error: Error CS8370 Feature 'range operator' is not available in C# 7.3. Please use language version 8.0 or greater.
In the C# project (GalleryApp) I've modified the project file:
but the error is still there.
I've inserted this line of code (#error version) to the GalleryApp.Models.IPhotoImporter:
result: Error CS8304 Compiler version: '3.11.0-4.22108.8 (d9bef045)'. Language version: 8.0.
and to the GalleryApp.IOS.PhotoImporter:
result: Error CS8304 Compiler version: '3.11.0-4.22108.8 (d9bef045)'. Language version: 7.3. GalleryApp.iOS
It means, that by modifying the Project file the following tag <LangVersion>8.0</LangVersion> will affect to the particular project, but not by the solution in general.
Than, I was trying to modify the property of the Gallery.IOS project (by choosing the specific version of the C# = 8.0) -> Properties -> Build -> Advances = but the Language version is not editable - (The latest C# compiler determines a default language version based on your project's target framework or frameworks) - my target framework for this solution is 2.1 and I'm not able to choose another version (3.0) in the lookup.
I've asked this question in the stackoverflow and I've receive one comment (which I've tried but it doesn't helped)
The comment from stackoverflow:
"You can't (currently) change xamarin to anything newer than .netstandard2.1. But that should automatically support c# 8, so the error is puzzling. First, make sure Visual Studio is up to date. Then, I recommend creating a new xamarin project, and testing c# 8 features in that. If that works, then it may be easiest to add all your source files to that new project. Alternatively, compare its csproj to yours - there must be some difference.
– ToolmakerSteve Jul 16 at 18:11"
Any idea how to overcome this?
The stucture of my Xamarin solution is:
GalleryApp
Models
IPhotoImporter
GalleryApp.Android
GalleryApp.IOS
PhotoImporter : IPhotoImporter
After a while, I've reached the chapter, which produces the following code (in iOS project in PhotoImporter class):
C#:
foreach (PHAsset asset in results[startIndex..endIndex])
{
var filename = (NSString)asset.ValueForKey((NSString)"filename");
RequestImage(photos, asset, filename, options);
}
return photos;
this code [startIndex..endIndex] throws an error: Error CS8370 Feature 'range operator' is not available in C# 7.3. Please use language version 8.0 or greater.
In the C# project (GalleryApp) I've modified the project file:
C#:
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
but the error is still there.
I've inserted this line of code (#error version) to the GalleryApp.Models.IPhotoImporter:
result: Error CS8304 Compiler version: '3.11.0-4.22108.8 (d9bef045)'. Language version: 8.0.
and to the GalleryApp.IOS.PhotoImporter:
result: Error CS8304 Compiler version: '3.11.0-4.22108.8 (d9bef045)'. Language version: 7.3. GalleryApp.iOS
It means, that by modifying the Project file the following tag <LangVersion>8.0</LangVersion> will affect to the particular project, but not by the solution in general.
Than, I was trying to modify the property of the Gallery.IOS project (by choosing the specific version of the C# = 8.0) -> Properties -> Build -> Advances = but the Language version is not editable - (The latest C# compiler determines a default language version based on your project's target framework or frameworks) - my target framework for this solution is 2.1 and I'm not able to choose another version (3.0) in the lookup.
I've asked this question in the stackoverflow and I've receive one comment (which I've tried but it doesn't helped)
The comment from stackoverflow:
"You can't (currently) change xamarin to anything newer than .netstandard2.1. But that should automatically support c# 8, so the error is puzzling. First, make sure Visual Studio is up to date. Then, I recommend creating a new xamarin project, and testing c# 8 features in that. If that works, then it may be easiest to add all your source files to that new project. Alternatively, compare its csproj to yours - there must be some difference.
– ToolmakerSteve Jul 16 at 18:11"
Any idea how to overcome this?