Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .NET 4.0 #227

Open
maf-soft opened this issue Nov 10, 2021 · 10 comments
Open

Support .NET 4.0 #227

maf-soft opened this issue Nov 10, 2021 · 10 comments

Comments

@maf-soft
Copy link

I'm developing with .NET 4.0 because I have to support Windows Server 2003.

I'm happy that I can use async await anyway.

So maybe it is not much effort to enable device.net for .NET 4.0, too?

@MelbourneDeveloper
Copy link
Owner

@maf-soft .net only introduced async await in 4.5. I think that's the minimum.

@maf-soft
Copy link
Author

maf-soft commented Nov 10, 2021

I'm using it with 4.0 and Visual Studio Community 2019: https://www.nuget.org/packages/Microsoft.Bcl.Async/

i.e. await serialPort.BaseStream.ReadAsync() works well, including CancellationToken.
(But now I need USB HID, too. It's the same device, providing RS232 and USB for the same data. Unfortunately it's doesn't install a virtual com port. If there is any way to get a virtual com port for this USB device, my application could work without changes...)

@MelbourneDeveloper
Copy link
Owner

@maf-soft fair point.

Are you interested in helping to see if it's possible to target 4.0?

I can give you a few pointers if you want to try it out.

If it works, you can submit a PR

@maf-soft
Copy link
Author

Ok, I cannot invest a lot of time, but If you think it's not much effort, I can try with your pointers. Should we talk somewhere else?

@MelbourneDeveloper
Copy link
Owner

@maf-soft I think it will be possible to some extent but there is going to be a lot of fiddly work involved.

I changed the csproj file to this as an example:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFrameworks>net4;</TargetFrameworks>
        <NoWarn>NU5125</NoWarn>
        <DocumentationFile>Device.Net.xml</DocumentationFile>
        <DebugType>embedded</DebugType>
    </PropertyGroup>
    <ItemGroup>
      <Compile Remove="DeviceDataStreamer.cs" />
    </ItemGroup>
    <ItemGroup>
        <None Include="..\..\README.md" Link="README.md" />
        <PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />


		<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.1">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
    </ItemGroup>
</Project>

These are the compilation errors I get. You would need to find more BCL libraries.
image

@MelbourneDeveloper
Copy link
Owner

@MelbourneDeveloper
Copy link
Owner

@maf-soft if you want to, you can create your own equivalent interface and list implementations...

@maf-soft
Copy link
Author

Thanks for your investigations and the link. Let's see when I find some time to look at it.

@maf-soft
Copy link
Author

According to https://docs.microsoft.com/en-us/dotnet/framework/install/guide-for-developers, .net 4.0, .net 4.5 and even .net 4.5.1 are officially abandoned starting from VS2022.

@danielchalmers
Copy link

wanted to note that .NET 4.6.2 is the earliest version that's officially supported by Microsoft as of April 26th: https://devblogs.microsoft.com/dotnet/net-framework-4-5-2-4-6-4-6-1-will-reach-end-of-support-on-april-26-2022

Customers currently using .NET Framework 4.5.2, 4.6, or 4.6.1 need to update their deployed runtime to a more recent version – at least .NET Framework 4.6.2 before April 26, 2022 – in order to continue to receive updates and technical support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants