zoukankan      html  css  js  c++  java
  • 比.Net Micro Framework还小的.net Framework

    这是飞天的最新一款智能卡产品,前短时间抽时间研究了一下,整体感觉还不错,实现了clr中有关文件操作(有些函数好像有些问题)、加密算法等指令。

     

     

     

     

    由于我们这边的项目组开发的就是MF3.0的文件系统,所以对它们这个这么小的东东有CPU、有操作系统,支持clr,并且支持文件系统很感兴趣。

    它的文件系统是FAT16MF实现的是FAT32,这就要求存储空间至少有32.52M),通过PC上的一个程序可以实现上下传文件。此外该系统最大的特点就是可以执行.net程序。

      

    下面是简单的程序,一个是运行在智能卡上(server),一个运行在普通PC上。

    //服务端程序,需要用上面的工具(load file)把编译好的程序上传到智能卡上,然后在设置运行即可。

    using System;

    using System.Runtime.Remoting;

    using System.Runtime.Remoting.Channels;

    using SmartCard.Runtime.Remoting.Channels.APDU;

    namespace MyCompany.MyOnCardApp

    {

        ///< Abstract >

        /// MyServer Abstract .

        ///</ Abstract >

        public class MyServer

        {

            ///< Abstract >

            ///URI of remote object to be exposed

            ///</ Abstract >

            private const string REMOTE_OBJECT_URI = "MyService.uri";

            ///< Abstract >

            ///Register Card Service

            ///</ Abstract >

            ///<returns></returns>

            public static int Main()

            {

                //Register communication channel for server to start listening

                ChannelServices.RegisterChannel(new APDUServerChannel());

                //Register application as a service

                RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService), REMOTE_OBJECT_URI, WellKnownObjectMode.Singleton);

                return 0;

            }

       }

    }

    //客户端程序,在PC机上运行,可以远程执行服务端上的函数有点DCOM的感觉。

    using System;

    using System.Runtime.Remoting;

    using System.Runtime.Remoting.Channels;

    using SmartCard.Runtime.Remoting.Channels.APDU;

    using System.Text;

    using MyCompany.MyOnCardApp;

    // Make sure the stub of the server application bas been added as reference or its interface has been declared

    // stub file is automatically generated in [Server Project Output]"Stub when compiling server application

    namespace MyCompany.MyClientApp

    {

        public class MyClient

        {

            private const string URL = "apdu://selfdiscover/MyService.uri";

            public static void Main()

            {

                // Create and register a communication channel

                APDUClientChannel channel = new APDUClientChannel();

                ChannelServices.RegisterChannel(channel);

                // Get reference to remote object

                MyService service = (MyService)Activator.GetObject(typeof(MyService), URL);

                // Call remote method

                service.FileOperation();

                // Unregister communication channel

                ChannelServices.UnregisterChannel(channel);

                               channel.Dispose();

            }

        }

    }

  • 相关阅读:
    SGU 495 Kids and Prizes 概率DP 或 数学推理
    poj 2799 IP Networks 模拟 位运算
    uva 202 Repeating Decimals 模拟
    poj 3158 Kickdown 字符串匹配?
    uva 1595 Symmetry 暴力
    uva 201 Squares 暴力
    uva 1594 Ducci Sequence 哈希
    uva 1368 DNA Consensus String 字符串
    数字、字符串、列表的常用操作
    if条件判断 流程控制
  • 原文地址:https://www.cnblogs.com/yefanqiu/p/1301451.html
Copyright © 2011-2022 走看看