2

There is an variable named leaveOpen in cryptostream which is available in **windows ** but not in xamarin. If true then stream won't be close automatically.

return new CryptoStream(
    stream: FileStream,
    transform: AES.CreateDecryptor(),
    mode: CryptoStreamMode.Read,
    leaveOpen: true       
);

enter image description here

enter image description here

So my problem is that argument which is not available in Xamarin. So whats the problem and how can solve it ? I have many alternatives but I want to use that only.

Sorry IwontTell
  • 466
  • 10
  • 29

1 Answers1

3

You can change target framework of your share project to .NetStandard 2.1.

Right click your forms project --> Properties -> Application --> Target framework:

enter image description here

    CryptoStream  stream = new CryptoStream(
        stream: FileStream,
        transform: AES.CreateDecryptor(),
        mode: CryptoStreamMode.Read,
        leaveOpen: true
    );

The document is here.

nevermore
  • 15,432
  • 1
  • 12
  • 30
  • 1
    Hi first special thanks for doing such great research. But I have some doubts. – Sorry IwontTell Aug 17 '20 at 08:22
  • (1) My project is not showing 2.1 or upper standards even installing .net Core runtimes + sdk for development. – Sorry IwontTell Aug 17 '20 at 08:23
  • 1
    (2) The doc link you have sent says that it also available to these .net standards: 2.1,2.0,1.6,1.4,1.3. So my current version is 2.0. – Sorry IwontTell Aug 17 '20 at 08:23
  • 1. Are you using the latest visual-studio 2019? 2. No, if I change to .netstandard 2.0, there is only one constructor there, see [doc](https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.cryptostream.-ctor?view=netstandard-2.0). Available there means CryptoStream is available. – nevermore Aug 17 '20 at 08:29
  • So now what will you recommend ? (1) I am using VS2017 15.9.26. (2)Yes right I got it. – Sorry IwontTell Aug 17 '20 at 09:29
  • 1
    I would recommend to use a VS2019:). – nevermore Aug 17 '20 at 09:30
  • I also wanted to use 2019. But my pc don't allow me to do this. VS2019 is heavy and has unsolvable errors. – Sorry IwontTell Aug 17 '20 at 09:33
  • No, VS2019 is not heavy and it is new with many features which 2017 does not have. You will finally switch to VS2019 in the future. – nevermore Aug 17 '20 at 09:37
  • @MuhammadAli If my answer helps you, can you please accept it (click the ☑️ in the upper left corner of this answer ) so that we can help more people with same problem:). – nevermore Aug 17 '20 at 09:38
  • Hi I have less ram pc, So I can verify that VS17 is more simple and fast loadup. I don't extra features if it can even build an apk. I will switch if I have good pc. You can see my errors in VS19 here https://stackoverflow.com/q/63187550/11390822 – Sorry IwontTell Aug 17 '20 at 09:39
  • Looks logical so making it tick – Sorry IwontTell Aug 17 '20 at 09:40
  • 1
    Well, I would say visual-studio 2019 is the future:). You can do some research to check if there is any way to let Visual-studio 2017 support .netstandard 2.1. – nevermore Aug 17 '20 at 09:42