---
title: "比.Net Micro Framework还小的.net Framework"
author: "mmdev"
date: "2008-09-28T14:08:00Z"
tags: []
slug: "net-micro-framework-net-framework"
draft: false
lastmod: "2012-08-04T21:26:04Z"
id: 1620881
url: "https://mmdev.iteye.com/blog/1620881"
---

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

&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;shapetype id="\_x0000\_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;stroke joinstyle="miter"&gt;&lt;/stroke&gt;&lt;formulas&gt;&lt;f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/f&gt;&lt;f eqn="sum @0 1 0"&gt;&lt;/f&gt;&lt;f eqn="sum 0 0 @1"&gt;&lt;/f&gt;&lt;f eqn="prod @2 1 2"&gt;&lt;/f&gt;&lt;f eqn="prod @3 21600 pixelWidth"&gt;&lt;/f&gt;&lt;f eqn="prod @3 21600 pixelHeight"&gt;&lt;/f&gt;&lt;f eqn="sum @0 0 1"&gt;&lt;/f&gt;&lt;f eqn="prod @6 1 2"&gt;&lt;/f&gt;&lt;f eqn="prod @7 21600 pixelWidth"&gt;&lt;/f&gt;&lt;f eqn="sum @8 21600 0"&gt;&lt;/f&gt;&lt;f eqn="prod @7 21600 pixelHeight"&gt;&lt;/f&gt;&lt;f eqn="sum @10 21600 0"&gt;&lt;/f&gt;&lt;/formulas&gt;&lt;path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/path&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;lock aspectratio="t" v:ext="edit"&gt;&lt;/lock&gt;&lt;/shapetype&gt;&lt;shape id="图片\_x0020\_0" style="VISIBILITY: visible; WIDTH: 319.8pt; HEIGHT: 214.2pt; mso-wrap-style: square" alt="feitian002.jpg" type="#\_x0000\_t75" o:spid="\_x0000\_i1027"&gt;&lt;imagedata o:title="feitian002" src="file:///D:/Users/v-hongfl/AppData/Local/Temp/msohtmlclip1/01/clip\_image001.jpg"&gt;&lt;/imagedata&gt;&lt;/shape&gt;

![](http://p.blog.csdn.net/images/p_blog_csdn_net/yefanqiu/EntryImages/20080928/feitian002.jpg)

&lt;shape id="图片\_x0020\_1" style="VISIBILITY: visible; WIDTH: 415.2pt; HEIGHT: 320.4pt; mso-wrap-style: square" alt="feitian001.jpg" type="#\_x0000\_t75" o:spid="\_x0000\_i1026"&gt;&lt;imagedata o:title="feitian001" src="file:///D:/Users/v-hongfl/AppData/Local/Temp/msohtmlclip1/01/clip\_image003.jpg"&gt;&lt;font face="Calibri" color="#000000" size="3"&gt;&lt;/font&gt;&lt;/imagedata&gt;&lt;/shape&gt;

![](http://p.blog.csdn.net/images/p_blog_csdn_net/yefanqiu/EntryImages/20080928/feitian001.jpg)

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

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

&lt;shape id="图片\_x0020\_2" style="VISIBILITY: visible; WIDTH: 415.2pt; HEIGHT: 310.2pt; mso-wrap-style: square" alt="feitian003.jpg" type="#\_x0000\_t75" o:spid="\_x0000\_i1025"&gt;&lt;imagedata o:title="feitian003" src="file:///D:/Users/v-hongfl/AppData/Local/Temp/msohtmlclip1/01/clip\_image005.jpg"&gt;&lt;font color="#000000" size="3"&gt;&lt;/font&gt;&lt;/imagedata&gt;&lt;/shape&gt;

![](http://p.blog.csdn.net/images/p_blog_csdn_net/yefanqiu/EntryImages/20080928/feitian003.jpg)

下面是简单的程序，一个是运行在智能卡上（server），一个运行在普通PC上。

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

using System;

using System.Runtime.Remoting;

using System.Runtime.Remoting.Channels;

using SmartCard.Runtime.Remoting.Channels.APDU;

namespace MyCompany.MyOnCardApp

{

///&lt; Abstract &gt;

/// MyServer Abstract .

///&lt;/ Abstract &gt;

public class MyServer

{

///&lt; Abstract &gt;

///URI of remote object to be exposed

///&lt;/ Abstract &gt;

private const string REMOTE\_OBJECT\_URI = "MyService.uri";

///&lt; Abstract &gt;

///Register Card Service

///&lt;/ Abstract &gt;

///&lt;returns&gt;&lt;/returns&gt;

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();

}

}

}