• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 42  文章 - 3  trackbacks - 0
            <2011年12月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            網頁收藏

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜


            This note is about book .NET and COM.

            Think of XML Web services simply as components or Application Programming Interfaces (APIs) exposed on a Web site rather than a DLL residing on your own computer.

            An assembly is a self-describing logical component. Assemblies are units of deployment, units of security, units of versioning, and units of scope for the types contained within. Although an assembly is typically one executable or one DLL, it could be made up of multiple files. 

            Any assemblies with type definitions contain corresponding type information describing them. This information is called metadata (data about data). 

            Reflection
             is the process of programmatically obtaining type information. Programs can dynamically inspect (“reflect upon”) the metadata for any assemblies, dynamically instantiate objects and invoke members, and even emit metadata dynamically (a technology called Refection Emit). Reflection provides late binding facilities like COM’s IDispatch and IDispatchEx interfaces, type inspection like COM’s ITypeInfo and ITypeInfo2 interfaces, and much more.

            How Unmanaged Code Interacts with Managed Code

            Three technologies exist that enable the interaction between unmanaged and managed code:

            • Platform Invocation Services (PInvoke)

               1 static class GameSharp
               2 {
               3     /// The native methods in the DLL's unmanaged code.
               4     internal static class UnsafeNativeMethods
               5     {
               6     const string _dllLocation = "CoreDLL.dll";
               7     [DllImport(_dllLocation)]
               8     public static extern void SimulateGameDLL(int a, int b);
               9     }
              10 }

              Choosing a Calling Convention

              The calling convention of an entry point can be specified using another DllImportAttribute named parameter, called CallingConvention. The choices for this are as follows:

              • CallingConvention.Cdecl. The caller is responsible for cleaning the stack. Therefore, this calling convention is appropriate for methods that accept a variable number of parameters (like printf).

              • CallingConvention.FastCall. This is not supported by version 1.0 of the .NET Framework.

              • CallingConvention.StdCall. This is the default convention for PInvoke methods running on Windows. The callee is responsible for cleaning the stack.

              • CallingConvention.ThisCall. This is used for calling unmanaged methods defined on a class. All but the first parameter is pushed on the stack since the first parameter is the this pointer, stored in the ECX register.

              • CallingConvention.Winapi. This isn’t a real calling convention, but rather indicates to use the default calling convention for the current platform. On Windows (but not Windows CE), the default calling convention is StdCall.

              Declare always uses Winapi, and the default for DllImportAttribute is also Winapi. As you might guess, this is the calling convention used by Win32 APIs, so this setting doesn’t need to be used in this chapter’s examples.

               1 using System;
               2 using System.Runtime.InteropServices;
               3 
               4 public class LibWrap
               5 {
               6 // C# doesn't support varargs so all arguments must be explicitly defined. 
               7 // CallingConvention.Cdecl must be used since the stack is  
               8 // cleaned up by the caller. 
               9 
              10 // int printf( const char *format [, argument] )
              11 
              12 [DllImport("msvcrt.dll", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.Cdecl)]
              13 public static extern int printf(String format, int i, double d); 
              14 
              15 [DllImport("msvcrt.dll", CharSet=CharSet.Unicode, CallingConvention=CallingConvention.Cdecl)]
              16 public static extern int printf(String format, int i, String s); 
              17 }
              18 
              19 public class App
              20 {
              21     public static void Main()
              22     {
              23         LibWrap.printf("\nPrint params: %i %f", 99, 99.99);
              24         LibWrap.printf("\nPrint params: %i %s", 99, "abcd");
              25     }
              26 }
            • Mixed-Mode Programming Using Managed Extensions to C++

            • COM Interoperability

                     

                  Good COM server implementation in C#

                  Building COM Objects in C#

                 Building COM Servers in .NET








            posted on 2013-06-27 03:32 鷹擊長空 閱讀(333) 評論(0)  編輯 收藏 引用
            精品久久久一二三区| 精品无码人妻久久久久久| 人妻无码久久一区二区三区免费 | 无码专区久久综合久中文字幕| 亚洲国产精品久久久天堂| 9久久9久久精品| 一级做a爰片久久毛片看看| 久久精品国产亚洲av麻豆色欲 | 亚洲美日韩Av中文字幕无码久久久妻妇| 国产精品99久久久久久宅男小说| 日韩av无码久久精品免费| 国内精品久久久久久麻豆| 色8久久人人97超碰香蕉987| 国产亚洲色婷婷久久99精品91| 久久婷婷五月综合色奶水99啪| 久久国产精品-久久精品| 久久精品成人欧美大片| 久久精品国产WWW456C0M| 老色鬼久久亚洲AV综合| 午夜精品久久影院蜜桃| 狠狠色婷婷综合天天久久丁香| 亚洲色大成网站www久久九| 久久久综合香蕉尹人综合网| 久久这里只有精品首页| 久久99久久99精品免视看动漫| 久久精品国产99国产精品亚洲| 久久久网中文字幕| 久久精品无码一区二区三区免费| 久久精品国产免费| 久久香蕉一级毛片| 久久夜色tv网站| 99久久精品久久久久久清纯| 青青草原1769久久免费播放| 国产高潮国产高潮久久久| 热re99久久6国产精品免费| 亚洲欧美日韩中文久久| 日本人妻丰满熟妇久久久久久| 亚洲精品高清国产一线久久| 亚洲国产精品一区二区久久hs| 久久久久亚洲av综合波多野结衣| 香蕉久久夜色精品国产尤物|