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
  1. Home
  2. The Lounge
  3. I thought .NET was supposed to make things easier, if anything, than unmanaged code.

I thought .NET was supposed to make things easier, if anything, than unmanaged code.

Scheduled Pinned Locked Moved The Lounge
csharpdatabasesql-servercomsysadmin
111 Posts 19 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H honey the codewitch

    it's mixed mode, as I understand it. Managed *and* unmanaged in the same PE. So it's not simply a .NET assembly but an assembly with a bag on the side of unmanaged code. I'm certain this was true when it was introduced. It probably still is. also i think there's still marshalling going on with managed->unmanaged calls in C++/CLI it might be more efficient than the standard marshalling though, but it's still marshalling.

    When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

    T Offline
    T Offline
    TheGreatAndPowerfulOz
    wrote on last edited by
    #96

    See here[^]

    #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

    H 1 Reply Last reply
    0
    • T TheGreatAndPowerfulOz

      See here[^]

      #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

      H Offline
      H Offline
      honey the codewitch
      wrote on last edited by
      #97

      yeah thanks. Though what zebra006 (sp?) showed me was more what I was after. Either way, it gives me a starting point.

      When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

      T 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        honey the codewitch wrote:

        Nobody made you respond to me.

        If you're a nobody, then yes.

        honey the codewitch wrote:

        Now I'm blocking you so I don't have to listen to this anymore.

        TMI - I don't need to know what you are doing on the internet.

        T Offline
        T Offline
        TheGreatAndPowerfulOz
        wrote on last edited by
        #98

        No reason to be an asshole.

        #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

        R 1 Reply Last reply
        0
        • H honey the codewitch

          I said they don't work how they are supposed to. How they were designed was to map files to a process address space so you could do pointer ops to read and write files. That is not doable under .NET. Sorry I've just explained this a lot. If you've used memory mapped files in unmanaged code then you know what i'm talking about. Otherwise you might never. I don't know. You cannot do var foo = new int[100000]; //backed by file. That's how it's supposed to work. It can't under .NET

          When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

          T Offline
          T Offline
          TheGreatAndPowerfulOz
          wrote on last edited by
          #99

          honey the codewitch wrote:

          It can't under .NET

          not even with "unsafe"?

          #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

          1 Reply Last reply
          0
          • Z zezba9000

            lol yes there is. You didn't read anything I said. As I said before. C# pointers are the same as C/C++. Look at the example below. I literally just compiled and ran this on my computer with zero errors.

            using System;
            using System.Runtime.InteropServices;

            using SIZE_T = System.IntPtr;
            using DWORD = System.UInt32;

            namespace TestNet
            {
            [StructLayout(LayoutKind.Sequential)]
            struct Foo
            {
            public int bar;
            }

            static class Program
            {
            	\[DllImport("Kernel32.dll")\]
            	private static unsafe extern void\* VirtualAlloc(void\* lpAddress, SIZE\_T dwSize, DWORD flAllocationType, DWORD flProtect);
            
            	private const DWORD MEM\_COMMIT = 0x00001000;
            	private const DWORD PAGE\_READWRITE = 0x04;
            
            	static unsafe void Main(string\[\] args)
            	{
            		Foo\* pfoo = (Foo\*)VirtualAlloc((void\*)0, (SIZE\_T)sizeof(Foo), MEM\_COMMIT, PAGE\_READWRITE);
            		pfoo->bar = 1; // writes to disk
            		Console.WriteLine(pfoo->bar.ToString()); // reads from disk.
            	}
            }
            

            }

            Make a C# console app and paste that code in. WaLa!!

            T Offline
            T Offline
            TheGreatAndPowerfulOz
            wrote on last edited by
            #100

            Thanks for sticking with it and being nice and teaching us all something new. :)

            #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

            1 Reply Last reply
            0
            • H honey the codewitch

              yeah thanks. Though what zebra006 (sp?) showed me was more what I was after. Either way, it gives me a starting point.

              When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

              T Offline
              T Offline
              TheGreatAndPowerfulOz
              wrote on last edited by
              #101

              ah yes, his example[^] is more succinct

              #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

              H 1 Reply Last reply
              0
              • T TheGreatAndPowerfulOz

                ah yes, his example[^] is more succinct

                #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #102

                i love it when i learn stuff, even if i have to be dragged to it. I'm only curious if this worked in early .NET and I just missed it before, or if it's a byproduct of me dropping development for years and only recently playing catch up.

                When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                T 1 Reply Last reply
                0
                • T TheGreatAndPowerfulOz

                  No reason to be an asshole.

                  #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                  R Offline
                  R Offline
                  Rajesh R Subramanian
                  wrote on last edited by
                  #103

                  You don't seem to be taking your own advice seriously - I see you deem it fit to be an unreasonable asshole by starting a discussion with someone by calling them an asshole.

                  T 1 Reply Last reply
                  0
                  • H honey the codewitch

                    i love it when i learn stuff, even if i have to be dragged to it. I'm only curious if this worked in early .NET and I just missed it before, or if it's a byproduct of me dropping development for years and only recently playing catch up.

                    When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                    T Offline
                    T Offline
                    TheGreatAndPowerfulOz
                    wrote on last edited by
                    #104

                    It worked in early .NET.

                    #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                    H 1 Reply Last reply
                    0
                    • T TheGreatAndPowerfulOz

                      It worked in early .NET.

                      #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #105

                      thanks. i always thought you had to copy out.

                      When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                      1 Reply Last reply
                      0
                      • R Rajesh R Subramanian

                        You don't seem to be taking your own advice seriously - I see you deem it fit to be an unreasonable asshole by starting a discussion with someone by calling them an asshole.

                        T Offline
                        T Offline
                        TheGreatAndPowerfulOz
                        wrote on last edited by
                        #106

                        Get a clue and take a hike.

                        #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                        R 1 Reply Last reply
                        0
                        • T TheGreatAndPowerfulOz

                          Get a clue and take a hike.

                          #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                          R Offline
                          R Offline
                          Rajesh R Subramanian
                          wrote on last edited by
                          #107

                          Go ahead, I'll follow your lead. In other words, don't preach what you don't practice. Or simply, follow your own advice.

                          T 1 Reply Last reply
                          0
                          • R Rajesh R Subramanian

                            Go ahead, I'll follow your lead. In other words, don't preach what you don't practice. Or simply, follow your own advice.

                            T Offline
                            T Offline
                            TheGreatAndPowerfulOz
                            wrote on last edited by
                            #108

                            You started this buddy by being a complete dick and jerk to another member here. You can finish it by just saying "I'm sorry -- won't happen again." Not to me, but to the other member. Or you can just sod-off. Until then expect to be treated by me like I see you treating others.

                            #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                            R 1 Reply Last reply
                            0
                            • T TheGreatAndPowerfulOz

                              You started this buddy by being a complete dick and jerk to another member here. You can finish it by just saying "I'm sorry -- won't happen again." Not to me, but to the other member. Or you can just sod-off. Until then expect to be treated by me like I see you treating others.

                              #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                              R Offline
                              R Offline
                              Rajesh R Subramanian
                              wrote on last edited by
                              #109

                              TheGreatAndPowerfulOz wrote:

                              ou started this buddy by being a complete dick and jerk to another member here

                              That's what you did, not me.

                              TheGreatAndPowerfulOz wrote:

                              You can finish it by just saying "I'm sorry -- won't happen again." Not to me, but to the other member. Or you can just sod-off.

                              I had an argument with another member (admittedly heated), and we're through that, and that's that. If you don't like that, you can sod-off (follow your own advice).

                              TheGreatAndPowerfulOz wrote:

                              xpect to be treated by me like I see you treating others

                              I should care? I might have had to take you seriously if you had anything to show as your own contribution to this community, like an article or a few awards. And you're trying to act like you've some business with how two other members have discussed, trolling on a two day old thread.

                              T 1 Reply Last reply
                              0
                              • R Rajesh R Subramanian

                                TheGreatAndPowerfulOz wrote:

                                ou started this buddy by being a complete dick and jerk to another member here

                                That's what you did, not me.

                                TheGreatAndPowerfulOz wrote:

                                You can finish it by just saying "I'm sorry -- won't happen again." Not to me, but to the other member. Or you can just sod-off.

                                I had an argument with another member (admittedly heated), and we're through that, and that's that. If you don't like that, you can sod-off (follow your own advice).

                                TheGreatAndPowerfulOz wrote:

                                xpect to be treated by me like I see you treating others

                                I should care? I might have had to take you seriously if you had anything to show as your own contribution to this community, like an article or a few awards. And you're trying to act like you've some business with how two other members have discussed, trolling on a two day old thread.

                                T Offline
                                T Offline
                                TheGreatAndPowerfulOz
                                wrote on last edited by
                                #110

                                Rajesh R Subramanian wrote:

                                That's what you did, not me. I had an argument with another member (admittedly heated),

                                Contradicting yourself. Typical sign of faulting thinking.

                                Rajesh R Subramanian wrote:

                                I should care? I might have had to take you seriously if you had anything to show as your own contribution to this community,

                                Yeah, you should care. As if you have anything to show yourself. Awards or no awards, doesn't matter. You should care how you interact with others. Be human. Not an animal.

                                #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                                R 1 Reply Last reply
                                0
                                • T TheGreatAndPowerfulOz

                                  Rajesh R Subramanian wrote:

                                  That's what you did, not me. I had an argument with another member (admittedly heated),

                                  Contradicting yourself. Typical sign of faulting thinking.

                                  Rajesh R Subramanian wrote:

                                  I should care? I might have had to take you seriously if you had anything to show as your own contribution to this community,

                                  Yeah, you should care. As if you have anything to show yourself. Awards or no awards, doesn't matter. You should care how you interact with others. Be human. Not an animal.

                                  #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                                  R Offline
                                  R Offline
                                  Rajesh R Subramanian
                                  wrote on last edited by
                                  #111

                                  Let me see if I could start it on a clean slate with you. Your primary accusation is that I started off by being rude to this other member. This is untrue, because my first two messages (on different parts of the thread) were: 1. A suggestion that a native programming language is more suitable for performance oriented tasks (not to mention the "should work across platforms" requirement). 2. The op pointed out some "flaws" with the .NET framework, which I said were basically not flaws, but by design. (how could one have raw pointers that could be used for manipulating memory on a framework that promises to automatically manage memory for you?!) The other person basically responded to me telling something amounting to "I worked for microsoft and I therefore don't need you telling me about .NET", which I did not like. I pointed out that working for microsoft doesn't automatically make someone very intelligent. The discussion went downhill from there, and the OP had some condescending stuff to say as well. A bit of back and forth, and the OP said they don't like me and that they will block me. I thought that was fair enough as we had had a heated exchange. But then you show up and falsely accuse me of "starting out by being a jerk" and here we are.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

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