MSDN Magazine - January 2008 - (Page 24) Guerrilla .NET February 4th - Los Angeles Guerrilla Connected Systems March 17th - Los Angeles Call 800 699 1932 to register today! or visit www.develop.com New - Hands-on .NET 3.0 Training What’s New in .NET 3.0 February 12th - Los Angeles However, if the native code keeps a copy of the pointer beyond the span of the call and intends to call back through that pointer later, you might need to use GCHandle to explicitly prevent the garbage collector from collecting the delegate. We must warn you that a pinned GCHandle could have a significantly negative impact on program performance. Fortunately, in this case, you don’t need to allocate a pinned GC handle, because the thunk is allocated in the unmanaged heap and is referencing the delegate indirectly through a reference known to the GC. Therefore, it is not possible for the thunk to move around, and native code should always be able to call the delegate through the unmanaged pointer if the delegate itself is alive. Marshal.GetFunctionPointerForDelegate can convert a delegate to a function pointer, but it doesn’t do anything to guarantee the lifetime of the delegate. Consider the following function declaration: public delegate void PrintInteger(int n); [DllImport(@”MarshalLib.dll”, EntryPoint=”CallDelegate”)] public static extern void CallDelegateDirectly( IntPtr printIntegerProc); Windows Communication Foundation January 8th - Los Angeles February 5th - New York February 26th - March 1st - Boston Windows Presentation Foundation January 14th - New York January 28th - Boston February 25th - Boston March 10th - Los Angeles If you call Marshal.GetFunctionPointerForDelegate for it and store the returned IntPtr, then pass the IntPtr to the function you are going to call, like so: IntPtr printIntegerCallback = Marshal.GetFunctionPointerForDelegate( new Lib.PrintInteger(MyPrintInteger)); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); CallDelegateDirectly(printIntegerCallback); Windows WorkFlow Foundation January 28th - Los Angeles March 10th - Los Angeles March 10th - Boston NEW COURSE Code Smarter With Design Patterns in .NET On-Site Training For groups of students, DevelopMentor’s On-Site course delivery may offer the most cost-effective solution – at your location, at the time you need it. OnSites also offer the ability to customize a course to your group’s needs, including course content, labs that run on your programming platform and lab exercises tailored to your business or project. Call us today to discuss your training needs! US -800.699.1932 UK -(0) 8000.562.265 Europe-(0)01242.525.108 msdnmagazine CLR Inside Out It is possible that the delegate will be collected before you call CallDelegateDirectly, and you will get an MDA error that CallbackOnCollectedDelegate was detected. To fix that, you can either store a reference to the delegate in memory or allocate a GC handle. If native code returns an unmanaged function pointer to the CLR, it is the responsibility of native code to keep the actual function code around. Usually this isn’t a problem unless the code is in a dynamically loaded DLL or generated on the fly. P/Invoke Interop Assistant Understanding and remembering all the attributes and rules described so far may seem a bit daunting. After all, most developers of managed code just need to be able to quickly figure out the P/Invoke signature for a Win32® API function, paste it in their code, and be done with it. That’s where the P/Invoke Interop Assistant (available at the MSDN Magazine Web site) can help. This tool can efficiently assist with conversions from C++ to managed P/Invoke signatures as well as those in the opposite direction. It even comes with a database of Win32 functions, data types, and constants, so the common task of adding a Win32 P/Invoke to your C# or Visual Basic source file is made very easy. The tool package includes two command-line tools, SigImp and SigExp, which can be used for batch file processing. A GUI tool is also found in the package, which includes the functionalities of both tools. The GUI tool is handy for doing simple conversions. It contains http://www.develop.com http://www.develop.com
Table of Contents Feed for the Digital Edition of MSDN Magazine - January 2008 MSDN Magazine - January 2008 Contents Toolbox CLR Inside Out Data Points Advanced Basics Cutting Edge IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline World Ready - Around the World with ASP.NET AJAX Applications WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 Wicked Code Foundations Extreme ASP.NET {End Bracket} MSDN Magazine - January 2008 MSDN Magazine - January 2008 - Contents (Page Cover1) MSDN Magazine - January 2008 - Contents (Page Cover2) MSDN Magazine - January 2008 - Contents (Page 1) MSDN Magazine - January 2008 - Contents (Page 2) MSDN Magazine - January 2008 - Contents (Page 3) MSDN Magazine - January 2008 - Contents (Page 4) MSDN Magazine - January 2008 - Contents (Page 5) MSDN Magazine - January 2008 - Contents (Page 6) MSDN Magazine - January 2008 - Contents (Page 7) MSDN Magazine - January 2008 - Contents (Page 8) MSDN Magazine - January 2008 - Contents (Page 9) MSDN Magazine - January 2008 - Contents (Page 10) MSDN Magazine - January 2008 - Toolbox (Page 11) MSDN Magazine - January 2008 - Toolbox (Page 12) MSDN Magazine - January 2008 - Toolbox (Page 13) MSDN Magazine - January 2008 - Toolbox (Page 14) MSDN Magazine - January 2008 - Toolbox (Page 15) MSDN Magazine - January 2008 - Toolbox (Page 16) MSDN Magazine - January 2008 - CLR Inside Out (Page 17) MSDN Magazine - January 2008 - CLR Inside Out (Page 18) MSDN Magazine - January 2008 - CLR Inside Out (Page 19) MSDN Magazine - January 2008 - CLR Inside Out (Page 20) MSDN Magazine - January 2008 - CLR Inside Out (Page 21) MSDN Magazine - January 2008 - CLR Inside Out (Page 22) MSDN Magazine - January 2008 - CLR Inside Out (Page 23) MSDN Magazine - January 2008 - CLR Inside Out (Page 24) MSDN Magazine - January 2008 - CLR Inside Out (Page 25) MSDN Magazine - January 2008 - CLR Inside Out (Page 26) MSDN Magazine - January 2008 - Data Points (Page 27) MSDN Magazine - January 2008 - Data Points (Page 28) MSDN Magazine - January 2008 - Data Points (Page 29) MSDN Magazine - January 2008 - Data Points (Page 30) MSDN Magazine - January 2008 - Data Points (Page 31) MSDN Magazine - January 2008 - Data Points (Page 32) MSDN Magazine - January 2008 - Advanced Basics (Page 33) MSDN Magazine - January 2008 - Advanced Basics (Page 34) MSDN Magazine - January 2008 - Advanced Basics (Page 35) MSDN Magazine - January 2008 - Advanced Basics (Page 36) MSDN Magazine - January 2008 - Advanced Basics (Page 37) MSDN Magazine - January 2008 - Advanced Basics (Page 38) MSDN Magazine - January 2008 - Advanced Basics (Page 39) MSDN Magazine - January 2008 - Advanced Basics (Page 40) MSDN Magazine - January 2008 - Advanced Basics (Page 41) MSDN Magazine - January 2008 - Advanced Basics (Page 42) MSDN Magazine - January 2008 - Cutting Edge (Page 43) MSDN Magazine - January 2008 - Cutting Edge (Page 44) MSDN Magazine - January 2008 - Cutting Edge (Page 45) MSDN Magazine - January 2008 - Cutting Edge (Page 46) MSDN Magazine - January 2008 - Cutting Edge (Page 47) MSDN Magazine - January 2008 - Cutting Edge (Page 48) MSDN Magazine - January 2008 - Cutting Edge (Page 49) MSDN Magazine - January 2008 - Cutting Edge (Page 50) MSDN Magazine - January 2008 - Cutting Edge (Page 51) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 52) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 53) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 54) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 55) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 56) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 57) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 58) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 59) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 60) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 61) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 62) MSDN Magazine - January 2008 - IIS 7.0 - Enhance Your Apps with the Integrated ASP.NET Pipeline (Page 63) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 64) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 65) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 66) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 67) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 68) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 69) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 70) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 71) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 72) MSDN Magazine - January 2008 - World Ready - Around the World with ASP.NET AJAX Applications (Page 73) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 74) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 75) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 76) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 77) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 78) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 79) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 80) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 81) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 82) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 83) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 84) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 85) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 86) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 87) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 88) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 89) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 90) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 91) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 92) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 93) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 94) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 95) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 96) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 97) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 98) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 99) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 100) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 101) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 102) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 103) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 104) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 105) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 106) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 107) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 108) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 109) MSDN Magazine - January 2008 - WCF Syndication - HTTP Programming with WCF and the .NET Framework 3.5 (Page 110) MSDN Magazine - January 2008 - Wicked Code (Page 111) MSDN Magazine - January 2008 - Wicked Code (Page 112) MSDN Magazine - January 2008 - Wicked Code (Page 113) MSDN Magazine - January 2008 - Wicked Code (Page 114) MSDN Magazine - January 2008 - Wicked Code (Page 115) MSDN Magazine - January 2008 - Wicked Code (Page 116) MSDN Magazine - January 2008 - Foundations (Page 117) MSDN Magazine - January 2008 - Foundations (Page 118) MSDN Magazine - January 2008 - Foundations (Page 119) MSDN Magazine - January 2008 - Foundations (Page 120) MSDN Magazine - January 2008 - Foundations (Page 121) MSDN Magazine - January 2008 - Foundations (Page 122) MSDN Magazine - January 2008 - Foundations (Page 123) MSDN Magazine - January 2008 - Foundations (Page 124) MSDN Magazine - January 2008 - Foundations (Page 125) MSDN Magazine - January 2008 - Foundations (Page 126) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 127) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 128) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 129) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 130) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 131) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 132) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 133) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 134) MSDN Magazine - January 2008 - Extreme ASP.NET (Page 135) MSDN Magazine - January 2008 - {End Bracket} (Page 136) MSDN Magazine - January 2008 - {End Bracket} (Page Cover3) MSDN Magazine - January 2008 - {End Bracket} (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.