Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Running full-trust, native, a... > Calling native libraries with P/Invo...

7.4. Calling native libraries with P/Invoke

We’ve looked at two ways to leverage native code in Azure: using FastCGI and spawning processes. The third option at your disposal is to call into a native library with P/Invoke. P/Invoke allows you to directly call a native library, such as a Windows dynamic link library (DLL). P/Invoke is shorthand for platform invoke. You use P/Invoke when you want to call a platform API directly. If you work mostly in .NET, you’re rarely calling the platform API directly; instead, you’re using classes out of the .NET Framework or the Base Class library.

The limitation with P/Invoke is that you can call only 64-bit native libraries while running in the cloud. If you happen to be developing on a 32-bit machine, you’ll be able to call a 32 bit-library locally, but not in the cloud. You can work around this problem by spawning a 32-bit subprocess, as outlined in section 7.3.1, and calling P/Invoke from there. We think this is too much work though; you should stick with 64-bit libraries.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint