Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

carloscs

@carloscs
About
Posts
14
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I DID IT!!!
    C carloscs

    Don't know if you're serious, but done that for my aunt that absolutely despises windows 10/11 ad ridden games. If you are serious, look at win7games.com, it has an installer for the old games that works in win 10/11. The only caveat I found is that windows update sometimes deletes the games and it needs a reinstall :)

    The Lounge javascript com cloud csharp

  • .NET's Sometimes Nonsensical Logic
    C carloscs

    One more for MS is right here (what??? how is that possible.) Not really different from what others already wrote, but this is how I see it... For me, Any(x) is the same as All(!x) so this must be true: if list.Any(x) == false then list.All(!x) == true which is true with the current implementation. What you expect results in: list.Any(x) == false and list.All(!x) == false. ... it's correct under your assumption, but to me it's illogic logic :).

    The Lounge csharp visual-studio question

  • Daily Build newsletter problem
    C carloscs

    It's very possible, that it only happens on Outlook: Defender complains about an attachment file in the temp folder (sorry, should also have posted this info). And it's not impossible that it's only in my pc: the email server is in a VM and has an Outlook Plugin that simulates an exchange server. It's possible that this plugin does something different than standard Outlook.

    The Lounge help question

  • Daily Build newsletter problem
    C carloscs

    Hi, For the past two days Microsoft Defender dislikes the daily build mail, saying it has a "Exploit:Win32/CVE-2017-11882!ml". Anyone else got this or is it just my Outlook+Defender that are misbehaving? Note: going through the browser webmail and opening the mail doesn't show any problem... Any ideas would be welcome...

    The Lounge help question

  • This makes zero sense - part deux
    C carloscs

    To add my useless reply, just can't resist :) Some years (15?) ago, had just that happen copying files between two linux servers. The useless part is that I can't remember what the problem was (need to refresh my memory sticks and backups). I seem to remember throwing one of the (somewhat old) servers to the trash as I come to the conclusion (after switching network cards, memory sticks, disks, ...) that the problem was motherboard related. Just a few tests you can do: - redirect the ssh stream to output and sum that to check if the problem is in the network stack or local. - write the file to disk instead of usb and do the sum on the disk file, the problem may be in writing to the usb. - if using wifi try using a network cable - if already using a network cable, try using a new one and(or connecting to a different port on the router/switch. As obermd wrote, I also had no errors anywhere to show that something odd was happening.

    The Lounge help csharp html database cryptography

  • Microsoft talking about ClickOnce
    C carloscs

    Sorry for the late answer, the mail sorter task sent the reply directly to the "read later" queue and the read task only started now. That task is really lazy, that queue now contains 1K+ entries :) Anyways, continuing the thread.. We leave ClickOnce pretty much alone and it just sorta keeps working... The clunky part is the management of deployed libraries, For example ... [searching memory...no entries found]. Ah, it all went away. Seems it's not only the good memories that go away with age. Thankfully I've not had to manage it in a long time. If I notice something strange I just poke the unfortunate low level hem, mail the unfortunate responsible for it about the problem.

    The Lounge csharp wpf winforms com question

  • Microsoft talking about ClickOnce
    C carloscs

    We have been using it for about 10 years now with 500 - 1000 users. We have 4 channels: - nightly build - internal power users - external power users - all users It works ok if somewhat clunky.

    The Lounge csharp wpf winforms com question

  • I found the perfect book on parsing
    C carloscs

    Fooled me the first time also: the top Title/link is for the pdf :) Seems like I need new four eyes, the link is only to an image. Hmm, the link seems to be PTAPG_1st_Edition[^] Found in freecomputerbooks.com website. It's still to the authors site, but don't know what to make of it...

    The Lounge json learning

  • I found the perfect book on parsing
    C carloscs

    If batting eyelashes doesn't work (hard to imagine)... :) The first edition is available for download on the (seemingly legit) author site: PTAPG_1st_Edition[^]

    The Lounge json learning

  • ELEPHANTING TEAMVIEWER!
    C carloscs

    Recently I was spammed with read in the Devolutions newsletter about Wayk Now - Instant Remote Support and Remote Desktop[^] their competitor to TeamViewer et al. I haven't tried it yet, but I've been using their Remote Desktop Manager Free for some years now without their being too intrusive, so I will likely try Wayk Now if/when I'll need remote access to somewhere.

    The Lounge sysadmin business help question

  • Windows 10 Pro
    C carloscs

    Ed Bott on ZDNet says it's still upgradable free: Here's how you can still get a free Windows 10 upgrade | ZDNet[^] Seems the free upgrade is still valid for people using assistive technologies, so if for example you sometimes use the Magnifier you're using an assistive technology and qualify for the free upgrade.

    The Lounge performance question announcement

  • c# Const vs. Readonly, Scope, Usings
    C carloscs

    Hmm... using the example on your other post (changed just enough to make the code compile):

    byte[] data = new byte[1000];
    MemoryStream memStream = new MemoryStream(data);
    CryptoStream decStream = new CryptoStream(memStream, SHA1.Create(), CryptoStreamMode.Read);

    using (StreamReader reader = new StreamReader(decStream)) {
    byte[] decryptedValue = Encoding.UTF8.GetBytes(reader.ReadToEnd());
    Console.WriteLine(decryptedValue);
    }

    We get a (for me accurate) CA2000 warning: object 'memStream' is not disposed along all exception paths. And... what's this, no warning about an undiposed decStream??? Let me check:

    SHA1 sha1 = SHA1.Create();
    byte[] data = new byte[1000];
    using (MemoryStream memStream = new MemoryStream(data)) {
    CryptoStream decStream = new CryptoStream(memStream, sha1, CryptoStreamMode.Read);

    StreamReader reader = new StreamReader(decStream);
    byte\[\] decryptedValue = Encoding.UTF8.GetBytes(reader.ReadToEnd());
    Console.WriteLine(decryptedValue);
    

    }

    No undisposed warnings with VS about this. Was going to say I could agree with this code, but no, even though it passes VS code analysis I disagree even more with it. Who can say what goes on in all the undisposed inner streams in the case of an exception? For me: a) (repeat from my other post) It seems that while VS2015 (and 2017, just tested) code analysis is smart enough to know that innerStream.Dispose calls outerSteam.Dispose it's not smart enough to know that Dispose in streams should be idempotent and should be able to be called several times. b) It's really strange there being a best practice that doesn't ensure every stream is closed in all code paths, including exceptions.

    The Lounge csharp database visual-studio business json

  • c# Const vs. Readonly, Scope, Usings
    C carloscs

    I agree that TextReader is a bad example for other reasons: probably the constructor doesn't throw. And I saw your other response, and it doesn't change things: it clarifies that Dispose does indeed call close on the outerStream, but it doesn't say a thing about what happens if the constructor throws. My point is that with:

    var outerStream = new AStream();
    using (var innerStream = new AnotherStream(outerStream)) {...}

    If "new AnotherStream(outerStream)" throws you get to hold the undisposed baby as innerStream.Dispose() never gets called and the outerStream isn't closed. Can't comment on VS code analysis, as I only use Resharper, but just for fun, trying VS2015 code analysis (all rules on) on this code:

    {
    var outerStream = new MyStream(); // line 59
    using (var innerStream = new MyStream(outerStream)) {
    bool i = innerStream.CanRead;
    Console.WriteLine("Read: " + i);
    }
    }
    {
    using (var outerStream = new MyStream())
    {
    using (var innerStream = new MyStream(outerStream))
    {
    bool i = innerStream.CanRead;
    Console.WriteLine("Read: " + i);
    }
    } // Line 73
    }

    [Line 59] Warning CA2000 In method 'Program.Main(string[])', call System.IDisposable.Dispose on object 'outerStream' before all references to it are out of scope. [Line 73] Warning CA2202 Object 'outerStream' can be disposed more than once in method 'Program.Main(string[])'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object. Bit schizophrenic: in the first case complains that Dispose isn't called and on the second complains that it's called twice :) Edit: - Moved Line 73 one line up... - VS code analysis agrees with me: the first warning says that with only one using it's not guaranteed that the outer stream gets closed. -(Re)thinking on this, VS code analysis is not smart enough: it knows that innerStream.Dispose() calls outerStream.Dispose() but doesn't know that Stream.Dispose() is (should always be) idempotent and can get called any number of times.

    The Lounge csharp database visual-studio business json

  • c# Const vs. Readonly, Scope, Usings
    C carloscs

    Foothill wrote:

    However, the proper way is this

    var outerStream = new MemoryStream(someData);
    using (var innerStream = new TextReader(outerStream)
    {
    // do something
    }

    This is because the a stream will dispose of the underlying streams when you call Stream.Dispose(). I had code analysis bark at me all the time until I figured this one out.

    No, it's not: if "new TextReader(outerStream)" throws you get an unclosed outerStream. The code analysis tool you're using is broken unless it can prove that the TextReader constructor never throws, and I really doubt that 1) it's doing that analisys and 2) that it's good practice to encourage not doing the outer using because in one specific case it's guaranteed the inner stream constructor doesn't throw.

    The Lounge csharp database visual-studio business json
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups