Cinchoo / ChoETL.NACHA

A NACHA library for .NET / c#
MIT License
37 stars 32 forks source link

Not compatible with .net standard #56

Open ForgeColeColon opened 10 months ago

ForgeColeColon commented 10 months ago

https://github.com/Cinchoo/ChoETL.NACHA/blob/a48e7d37e07abae3608a714c439f289764edf1ab/ChoETL.NACHA.Core/ChoETL.NACHA.NETStandard.csproj#L5

This is targetting .net core, not .net standard. The moment you try to instantiate NachaWriter in a .netstandard library, it errors with System.Runtime incompatibility.

Took days to figure this out, because the name of the project is literally ChoETL.NACHA.NetStandard. Should be NetCore.

chatbot702107 commented 9 months ago

So, are you saying you were able to fix the problem? Could you tell me a little more details about your code and which version of .NET you are using?

ForgeColeColon commented 9 months ago

Sure. I have a .csproj targeting netstandard2.0. I am not able to use NACHA.NetStandard because it is targetting netcoreapp2.1. If NACHA.NetStandard was targetting netstandard2.0, then it would be compatible with .net45, netstandard2.0, and all net core frameworks. I thought that might have been your goal with this version, but i could be wrong. So i was just throwing it out there that this is currently not compatible with netstandard2.0 projects.

chatbot702107 commented 9 months ago

hmmm, do you know if its compatible with anything like .NET6, .NET 7 or .NET 8? Based on what you said, it sounds like its only meant to work with those older deprecated frameworks...and not the new .NET stuff??

Thanks for responding so quickly.

ForgeColeColon commented 9 months ago

Yes it is. This was what my work around was. Since the .csproj I was using it in was netstandard2.0, I had to create a new project in net6.0 and install NACHA.NetStandard there in order to keep my other project in netstandard2.0 for nuget packaging reasons.

ForgeColeColon commented 9 months ago

Pasted simple project i just created targeting netstandard2.0 on how to reproduce.

chatbot702107 commented 9 months ago

I was bummed when my brand new .NET 8 project blew up when trying to use this ChoETL.Nacha nuget package in visual studio 2022. The C# code came from a .net 4.6.1 (4.6.2?) project that has worked fine for a while now. And after making the syntax changes to the .NET8 code, I tried to debug it and it blew up. Dang, it sounds like it might not be a lost cause.

I am so glad you are posting some stuff here. thank you!!!

ForgeColeColon commented 9 months ago

SimpleProj

ForgeColeColon commented 9 months ago

I believe if you just make the following change to your .csproj

<TargetFramework>netstandard2.0</TargetFramework>

everything should be fine. Would you mind trying it?

chatbot702107 commented 9 months ago

Oh wait a sec....the csproj file is set to<TargetFramework>net8.0</TargetFramework> since I created a brand new .NET8 project in visual studio, and just moved the old code into the new .NET8 project.

Because I wanted to move the old code into .NET8 while still using this choETL.NACHA. So when I changed target framework like this <TargetFramework>netstandard2.0</TargetFramework>

Then the compiler blows up, since there are .NET8 syntax/code changes made to some parts of the code (just like loops, declarations stuff like that, but the NACHA code didnt get changed yet).

So I am wondering if I can use this and still get this ChoETL.Nacha to work with: <TargetFramework>net8.0</TargetFramework>

ForgeColeColon commented 9 months ago

i meant the ChoETL.NACHA.NETStandard.csproj should be netstandard2.0. that will fix problems with all projects referencing it.

chatbot702107 commented 9 months ago

i meant the ChoETL.NACHA.NETStandard.csproj should be netstandard2.0. that will fix problems with all projects referencing it.

so are you talking about downloading the code (including the ChoETL.NACHA.NETStandard.csproj ) from github (not the nuget package that I am referencing now) and changing that target framework in that downloaded github code to be like this <TargetFramework>netstandard2.0</TargetFramework> and then recompile that code and use it in the .NET8 project?

PS Also, I opened up that file and see this: image

ForgeColeColon commented 9 months ago

correct, the netcoreapp2.1 is why it is currently not working.

chatbot702107 commented 9 months ago

OK, I see. Normally I dont download and use directly from github, since visual studio has some nuget packages available for the ChoETL stuff. But in this case, I see there is the sln file in github, and the files and folders etc. So I will give that a shot, download all of it, then (make the change) and recompile it in Visual studio.
PS Any thought on which version of vs.net I should use for compiling it?

Thanks!

ForgeColeColon commented 9 months ago

Yeah, sorry, i thought you were the code owner trying to fix this issue. This package works for me in .net 6. What breaks in .net 8?

chatbot702107 commented 9 months ago

ahh, nope not owner. Just a new user and it sounded like you were having maybe similar problem, so i thought I should at least ask. I am thinking if its working for your .NET 6, then it should hopefully work for me too in .NET8. That would be very good!

I posted an issue here. Basically it dies as soon as it tries to execute this in the for loop foreach (var data in new ChoNACHAReader(filename)) https://github.com/Cinchoo/ChoETL.NACHA/issues/57

ForgeColeColon commented 9 months ago

try this: var builder = new StringBuilder(File.ReadAllText(fileName)); foreach (var data in new ChoNACHAReader(builder)) {

        }
chatbot702107 commented 9 months ago

thanks. Will give it a try and let you know. :-)

ForgeColeColon commented 9 months ago

Did that end up working? I believe it should have, cause it bypasses the GetEncoding call that was causing your error.

chatbot702107 commented 9 months ago

Thanks again!.....So, been testing it, seems to have worked. Need to do more testing tomorrow though. I am wondering why GetEncoding was blowing up. Did you encounter issues with it blowing up in your .NET 6 app?