Comments on: Introduction to .NET Interoperability [...] more efficient than using C++/CLI, but not by all that much (in the grand scheme of things). As Promit wrote in his recent #AltDevBlogADay post, all available forms of managed/native interoperability are painful to an extent; the best way to [...] [...] more efficient than using C++/CLI, but not by all that much (in the grand scheme of things). As Promit wrote in his recent #AltDevBlogADay post, all available forms of managed/native interoperability are painful to an extent; the best way to [...]

]]>
By: Amir Ebrahimi/2011/03/31/introduction-to-net-interoperability/#comment-2458 Amir Ebrahimi Thu, 07 Apr 2011 20:48:57 +0000 Well apparently indenting is ok once submitted . But in preview it was messy! Well apparently indenting is ok once submitted . But in preview it was messy!

]]>
By: Gregory/2011/03/31/introduction-to-net-interoperability/#comment-2431 Gregory Thu, 07 Apr 2011 12:57:06 +0000 gist that contains the same code.

 
  public static class NativeMethods
 
  {
 
    [DllImport("kernel32")]
 
    private unsafe static extern void* LoadLibrary(string dllname);
 
    [DllImport("kernel32")]
 
    private unsafe static extern void FreeLibrary(void* handle);
 
    private sealed unsafe class LibraryUnloader
 
    {
 
      internal LibraryUnloader(void* handle)
 
      {
 
        this.handle = handle;
 
      }
 
      ~LibraryUnloader()
 
      {
 
        if (handle != null)
 
          FreeLibrary(handle);
 
      }
 
      private void* handle;
 
    } // LibraryUnloader
 
    private static readonly LibraryUnloader unloader;
 
    static NativeMethods()
 
    {
 
      string path;
 
      if (IntPtr.Size == 4)
 
        path = "path/to/the/32/bit/Foo.dll";
 
      else
 
        path = "path/to/the/64/bit/Foo.dll";
 
      unsafe
 
      {
 
        void* handle = LoadLibrary(path);
 
        if (handle == null)
 
          throw new DllNotFoundException("unable to find the native Foo library: " + path);
 
        unloader = new LibraryUnloader(handle);
 
      }
 
    }
 
  }
 
  
]]>
By: Don-Olmstead/2011/03/31/introduction-to-net-interoperability/#comment-2373 Don-Olmstead Tue, 05 Apr 2011 21:14:04 +0000 If you could give an example why PlatformInvoke was harmful in the SlimDX project, that would give me a better idea of when or when not to use it. I would mainly be interested in C++/CLI. Perhaps a tutorial approach. It seems the most logical as that is what you used with SlimDX. If you could give an example why PlatformInvoke was harmful in the SlimDX project, that would give me a better idea of when or when not to use it.

I would mainly be interested in C++/CLI. Perhaps a tutorial approach. It seems the most logical as that is what you used with SlimDX.

]]>
By: Triton/2011/03/31/introduction-to-net-interoperability/#comment-2245 Triton Sat, 02 Apr 2011 12:04:06 +0000 Heh, I've heard your rant along those lines at GDC 2010 and 2011 now, I believe :) The reflection thing is interesting, since in the middle part of the decade (circa VC 7.1 and GCC 3.x) when compiler support really got strong, a lot of studios (I think) started building C++/template based reflection systems. I've heard pretty consistently that attempting to merge these systems with .NET and that reflection system is absolutely disastrous. As for our work on SlimDX, it's been an adventure, maybe worthy of more documentation than it's gotten. I started in late 2006 as a response to XNA (which I perceived at the time as garbage, more on that some other time). The first design was a simple source compatible clone, which was eventually thrown out the following year and redesigned more or less ground up. Quantifying success on that front is difficult, but we have a lot of users in professional production environments using it who are happy -- I'll take it. Heh, I’ve heard your rant along those lines at GDC 2010 and 2011 now, I believe :)

The reflection thing is interesting, since in the middle part of the decade (circa VC 7.1 and GCC 3.x) when compiler support really got strong, a lot of studios (I think) started building C++/template based reflection systems. I’ve heard pretty consistently that attempting to merge these systems with .NET and that reflection system is absolutely disastrous.

As for our work on SlimDX, it’s been an adventure, maybe worthy of more documentation than it’s gotten. I started in late 2006 as a response to XNA (which I perceived at the time as garbage, more on that some other time). The first design was a simple source compatible clone, which was eventually thrown out the following year and redesigned more or less ground up. Quantifying success on that front is difficult, but we have a lot of users in professional production environments using it who are happy — I’ll take it.

]]>
By: Geoff Evans/2011/03/31/introduction-to-net-interoperability/#comment-2193 Geoff Evans Fri, 01 Apr 2011 01:55:33 +0000 Amazing work with SlimDX, I have been thinking about possibly converting to it for a while now. Right now, I do some pretty crude interop stuff between C# and C++ to get the benefits of each. Amazing work with SlimDX, I have been thinking about possibly converting to it for a while now. Right now, I do some pretty crude interop stuff between C# and C++ to get the benefits of each.

]]>
By: Mike Nicolella/2011/03/31/introduction-to-net-interoperability/#comment-2189 Mike Nicolella Thu, 31 Mar 2011 22:36:45 +0000