Can I use this SDK in .NET framework 4.5?

resident

Active member
Joined
May 8, 2023
Messages
25
Programming Experience
5-10
Hello.
Good time
I have a software based on .NET Framework 4.5 ( .net MVC) . I want to use the SDK that I posted the download link for.
I want to know if I can use this SDK?
I think the C# version of my software is different from the SDK.
I did not check other cases except C#.
SDK download link
 
Solution
Apparently, that package uses a feature from C# 9 where properties cannot be set arbitrarily but only when a class instance is initialised. Even if you do set the property then, if you're not using C# 9 or later, such properties are not supported. I just created a .NET Framework 4.8.1 project and installed that package from NuGet. I added this code to the Main method:
C#:
var dto = new InvoiceHeaderDto { Tins = "Hello World" };
and I got that error message. I clicked on the project node in the Solution Explorer, right-clicked and selected Unload Project. The project file was then opened in VS for editing. I added the following line into the project file and saved:
XML:
  <PropertyGroup>
    <Configuration Condition="...
Nothing in the code you have shown in the screenshots is dependent on that library you referenced.

"Go To Definition" only goes to where Visual Studio's in memory parser thinks something is defined. It may not match the reality of what is actually compiled into an assembly that is being used by the compiler. (Recall that VS != C# compiler.)

Anyway, do a clean build the project that contains the InvoiceHeaterDto, then next do a clean build of the assembly that contains HomeController. Make sure that everything is built as the same flavor (e.g. AnyCPU, Debug for all assemblies, or x64, Retail for all assemblies, etc.) Make sure that your are referencing the project, and not referencing the assembly.
 
In picture number 1 of the comment I posted above, I copied the codes from the guide document of the SDK provider company.

In the image I attached in this comment, I wrote the code myself.
As you can see, it does not display the class properties at all.
I was searching on the internet, the coding model of the codes provided by the SDK provider company is related to C# 9 (if I'm not mistaken).
Is it possible that the reason for not displaying the properties of the InvoiceHesderDto class is the mismatch of C# versions?

It should be noted that I am using Visual Studio 2017
 

Attachments

  • 3.png
    3.png
    16 KB · Views: 16
Last edited:
Is it possible that the reason for not displaying the properties of the InvoiceHesderDto class is the mismatch of C# versions?

No.

What is more likely is that the assembly you have doesn't match the code that "Go to definition" is showing you.

Try seeing if there is a set_Tins() method, since that new screenshot shows get_* methods.
 
No.

What is more likely is that the assembly you have doesn't match the code that "Go to definition" is showing you.

Try seeing if there is a set_Tins() method, since that new screenshot shows get_* methods.

No, it does not have set_...() function

I installed Visual Studio 2022 and targeted .net framework 4.7.2.
The properties of the InvoiceHeaderDto class were displayed.

I wanted to value the properties in the order of photo number 4, which gave the error in the image.
After that, I initialized the class in the way it was initialized in the SDK provider's documentation, it said that this method is available in C# 9 (image number 5)

I know that C# 9 comes from .NET 5
But my question is: Can I use C# 9 in .NET Framework 4.5 and later?
 

Attachments

  • 4.png
    4.png
    21.5 KB · Views: 17
  • 5.png
    5.png
    18.2 KB · Views: 17
Look at version support for .Net Framework.
No, 4.5 is not supported.
 
Look at version support for .Net Framework.
No, 4.5 is not supported.

thank you.
Yes I saw . I can upgrade to 4.8.1, but the problem I said exists.
If I upgrade .NET Framework to any version up to 4.8.1, can I use C# 9?
 
C# 9 requires .Net 5+.
 
I created a new project targeting .NET Framework 4.6.2 and added the SDK available in Nugget to my project.

But I still have the same problem when initialize the InvoiceHeatherDto properties, which finally says that C# 9 is required.

Thank you for checking if you have time. What is my problem that I can't use this SDK?
 
Apparently, that package uses a feature from C# 9 where properties cannot be set arbitrarily but only when a class instance is initialised. Even if you do set the property then, if you're not using C# 9 or later, such properties are not supported. I just created a .NET Framework 4.8.1 project and installed that package from NuGet. I added this code to the Main method:
C#:
var dto = new InvoiceHeaderDto { Tins = "Hello World" };
and I got that error message. I clicked on the project node in the Solution Explorer, right-clicked and selected Unload Project. The project file was then opened in VS for editing. I added the following line into the project file and saved:
XML:
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{86B97037-3A63-4406-89E1-920A1D782172}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Test.Console._481</RootNamespace>
    <AssemblyName>Test.Console.481</AssemblyName>
    <TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
    <LangVersion>9</LangVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <Deterministic>true</Deterministic>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>
I then right-clicked the project again and selected Reload Project. I could then build and run the project without that error.
 
Solution

Latest posts

Back
Top Bottom