作者:<wbr><a href="http://hi.csdn.net/space.php?uid=2519652"><span style="color: rgb(255, 0, 0);">摩羯·鑫</span><wbr></wbr></a><span style="color: rgb(255, 0, 0);"><wbr><wbr><wbr> 注: 转载请注明出处,谢谢<br> Blog:<wbr><a href="http://hi.csdn.net/space.php?uid=2519652">http://hi.csdn.net/space.php?uid=2519652</a><wbr><br> 本文地址:<a href="http://blog.csdn.net/zchin/archive/2010/08/06/5793010.aspx">http://blog.csdn.net/zchin/archive/2010/08/06/5793010.aspx</a></wbr></wbr></wbr></wbr></wbr></span></wbr>
<wbr></wbr>
网上很多让.net<wbr>程序脱离<span>.net framework</span><wbr>环境运行的方法:</wbr></wbr>
第一种是基于移动飞信的虚拟器,具体实现是<wbr><span style="font-family: 宋体; color: black;">在</span><wbr><span style="color: black;">VMDotNet<wbr></wbr></span><span style="font-family: 宋体; color: black;">目录里面会找到一个</span><wbr><span style="color: black;">FetionVM.exe<wbr></wbr></span><span style="font-family: 宋体; color: black;">。这个是虚拟环境的</span><wbr><span style="color: black;">loader</span><wbr><span style="font-family: 宋体; color: black;">。使用方法:</span><wbr><span style="color: black;">FetionVM.exe pathtoyoure.exe</span><wbr><span style="font-family: 宋体; color: black;">就是直接把你的</span><wbr><span style="color: black;">.Net<wbr></wbr></span><span style="font-family: 宋体; color: black;">程序</span><wbr><span style="font-family: 宋体; color: black;">作为命令行参数传递给</span><span style="color: black;">FetionVM.exe<wbr></wbr></span><span style="font-family: 宋体; color: black;">就可以在这个虚拟环境中执行你的.</span><wbr><span style="color: black;">net</span><wbr><span style="font-family: 宋体; color: black;">程序了。在这里就不详细介绍了。</span></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr><wbr><wbr> 第二种基于</wbr></wbr></wbr><wbr><span style="color: black;">mono</span><wbr><span style="font-family: 宋体; color: black;">的</span><wbr><span style="line-height: 21px; font-family: 宋体;">.net</span><wbr><span style="line-height: 21px; font-family: 宋体;">程序脱离<span>.net framework</span><wbr>环境运行。或许还有其他方法,现在</wbr></span><wbr><span style="font-family: 宋体; color: black;">详细介绍可以使</span><span style="line-height: 21px; font-family: 宋体;">.net</span><wbr><span style="line-height: 21px; font-family: 宋体;">程序脱离<span>.net framework</span><wbr>环境运行的另一种方法,基于<span>Remotesoft Liker</span><wbr>,具体步骤如下</wbr></wbr></span></wbr></wbr></wbr></wbr></wbr></wbr>
1<wbr><span style="line-height: 21px; font-family: 宋体;">、可先到<a href="http://download.csdn.net/source/2601256">http://download.csdn.net/source/2601256</a><wbr>下载</wbr></span><wbr><span style="line-height: 21px; font-family: 宋体;"><span>Remotesoft Liker</span><wbr></wbr></span><span style="line-height: 21px; font-family: 宋体;">程序包,解压后,包含两个压缩文件:</span></wbr></wbr>
<wbr><wbr><wbr><img src="https://i-blog.csdnimg.cn/blog_migrate/a4c26d1e5885305701be709a3d33442f.gif" real_src="http://hi.csdn.net/attachment/201008/6/2519652_12810688710UuN.jpg" alt="" width="130" height="130" style="border-width: 0pt; border-style: none; max-width: 100%;" title="C# net<wbr>程序脱离.net<wbr>framework"></wbr></wbr></wbr>
2<wbr><span style="line-height: 21px; font-family: 宋体;">、解压<span>RemoteSoft_Linker+2[1].1.rar<wbr></wbr></span>,包含<span>LinkerPatch.exe</span><wbr>和<span>Remotesoft_DOTNET_Linker_Evaluation_2.1.0_VS2005.msi</span><wbr>两个文件</wbr></wbr></span></wbr>
3<wbr><span style="line-height: 21px; font-family: 宋体;">、先安装<span>Remotesoft_DOTNET_Linker_Evaluation_2.1.0_VS2005.msi</span></span></wbr>
4<wbr><span style="line-height: 21px; font-family: 宋体;">、解压<span>Remotesoft_2[1].1.rar</span><wbr>,解压后,进入<span>Linker</span><wbr>目录,目录如下:</wbr></wbr></span></wbr>
5<wbr><span style="line-height: 21px; font-family: 宋体;">、此时,进入到<span>bin</span><wbr>目录</wbr></span></wbr>
<wbr></wbr>
6<wbr><span style="line-height: 21px; font-family: 宋体;">、进入之前解压的<span>RemoteSoft_Linker+2[1].1</span><wbr>目录,双击执行<span>LinkerPatch.exe</span></wbr></span></wbr>
<wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr>点击Browse…<wbr>按钮,进入<wbr><span>Remotesoft_2[1].1</span><wbr>对应解压目录的<span>bin</span><wbr>目录,并选择<span>mini_sta.exe</span><wbr>文件</wbr></wbr></wbr></wbr></wbr>
<wbr></wbr>
并点击Pathch<wbr>按钮。</wbr>
此时编译环境配置成功。
7<wbr><span style="line-height: 21px; font-family: 宋体;">、接下来,利用配置好的环境测试一下<span>.net</span><wbr>程序脱离<span>.net framework</span><wbr>环境运行,建立一个简单的<span>.net winform<wbr></wbr></span>桌面程序,并生成相应的执行程序。</wbr></wbr></span></wbr>
7.1 新建一个Windows窗体应用程序
7.2<wbr></wbr>在生成的默认窗体中加入两个.net<wbr></wbr>控件。简单的实现点击按钮button1<wbr>则改变<span>checkBox1</span><wbr>的选中状态。</wbr></wbr>
接下来,生成项目
运行效果如下:
7.3<wbr></wbr>进入之前解压的Remotesoft_2[1].1.new/Linker<wbr>目录,新建一个测试目录,这里我命名为:<span>NoFrameworkTestAppTest</span></wbr>
<wbr></wbr>
7.4<wbr></wbr>接下来到写好的winform<wbr>程序生成目录下拷贝运行文件:<span>NoFrameworkTestApp.exe</span><wbr>到</wbr></wbr>
Remotesoft_2[1].1.new/Linker/ NoFrameworkTestAppTest<wbr><span style="line-height: 21px; font-family: 宋体;">目录中,并建立一个批处理文件,对应下图中的<span>mdeploy.bat</span><wbr>。</wbr></span></wbr>
7.5<wbr></wbr>使用记事本打开mdeploy.bat<wbr>,写入以下命令保存并关闭:</wbr>
7.6<wbr></wbr>双击运行该批处理运行。
7.7<wbr></wbr>当该批处理命令运行结束后,会生成一个mdeployed<wbr>的文件夹,里面包含所有支持<span>winform</span><wbr>测试程序运行的<span>dll</span><wbr>文件和一些资源文件。</wbr></wbr></wbr>
好了,现在就可以将这个文件夹整个拷贝到没有装.net framework<wbr>环境的机器上运行看看效果了。</wbr>
8<wbr><span style="line-height: 21px; font-family: 宋体;">、在这里,为了演示该方法的可行性,我就拷贝到一个远程机器上,该机器上没有安装<span>.net framework</span><wbr>环境,所以你在试验的时候,也确认一下你试验的机器上是否安装了<span>.net framework</span><wbr>环境。免得白高兴一场 :)</wbr></wbr></span></wbr>
8.1
运行效果如下:
<wbr></wbr>
<wbr></wbr>