• ----:)欢迎访问源码网(:----
    • 首页
    • 博客
    • 学院
    • 下载
    • 论坛
    • 影视
    • 发布源码
    • RSS
    • ITPig
    • 笑话网
    • 百家姓
    • 繁體中文

源码网 - 中国第一源码门户
选择镜像:网通镜像 - 电信主站
  • 首 页
  • 新闻动态
  • 网站运营
  • 网页制作
  • WEB开发
  • 编程开发
  • 图像媒体
  • 操作系统
  • 数据库
  • 服务器
热门搜索 优化 SEO 故事 cms IIS7 MySQL 个人 AdSense 主题推广 | 文章搜索: 高级搜索
会员登录/控制面版您的位置: 学院首页 >> WEB开发 >> .NET 开发 >> 详细内容
 

推荐文章

 
 

热点文章

  • FckEditor远程图片下载插件
  • TFS(Team Foundation Server)使用经验
  • IIS过滤器实现.NET程序不破解DLL替换字符串一法
  • 为ASP.NET封装的SQL数据库访问类
  • ASP.NET2.0中文验证码的实现
  • Url地址重写,利用HttpHander手工编译页面并按需生成静..
  • ASP.NET学习笔记一——ASP和ASP.NET比较
  • 使用HtmlInputHidden 控件在本页面保持状态和跨页面传..
  • ASP.Net发邮件
  • Silverlight 2.0中文学习资源集萃
  • WinForm中使用XtraGrid控件,实现在界面中动态修改列显..
  • 解析ASP.NET木马文件操作
 
 

相关文章

  • Rotor实现中用到的Macro
  • .NET / Rotor源码分析5 - 开始使用WinDbg+SOS调试,ss..
  • .NET / Rotor源码分析4 - 修改Rotor使其发送CLR Notif..
  • .NET / Rotor源码研究3 – 调试Rotor托管代码的利器:W..
  • .NET / Rotor 源码研究2 – PAL Initialization / Term..
  • .NET / Rotor 源码研究1 - Building Rot
  • 谈.NET中几个怪异的CustomAttribute
  • .NET Main函数参数解释过程和特殊规则
  • .NET SDK中CorFlags.Exe的用法
  • .NET中的幕后英雄:MSCOREE.DLL
  • .NET Interop: 从IErrorInfo错误对象获得托管代码的异..
  • .NET牛人应该知道些什么
 
 

百度搜索

 
 

.NET/Rotor源码研究1补遗 - 解决无法检测操作系统版本的错误

  • 阅览次数:
  • 文章来源: http://blog.csdn.net/atfield
  • 原文作者: atfield
  • 整理日期: 2008-07-19
  • 发表评论
  • 字体大小:
  • 小
  • 中
  • 大

最近不少朋友反映在编译Rotor的时候出现无法检测操作系统版本的错误,具体现象为执行env.bat的时候报错:
 

Could not get platform OS version

 
 
出现该错误的原因是env.bat会调用env.core.pl设置环境,而env.core.pl在检测操作系统版本的时候会使用到ver命令的输出结果:

            if (Windows()) {

                            # The output of ver looks like:

                            #

                            # Microsoft Windows XP [Version 5.1.2600]

                            #

                            # (including the empty line before)

 

                            $platform_os_version = `ver`;

                            # we keep the first two fields of the version number

                            if (! ($platform_os_version =~ s/\nMicrosoft.*\[Version +([0-9]+\.[0-9]+)\..*\]/$1/g)) {

                                            $platform_os_version = "";

                            }
 

                            if ($platform_os_version =~ /^5\..*/) {

                                            $platform_os_version = "5.1";

                            }
            } else {

                            $platform_os_version = `uname -r`;

                            # we keep all fields of the version number

                            if (! ($platform_os_version =~ s/^[^0-9]*([0-9.]+).*$/$1/s)) {

                                            $platform_os_version = "";

                            }
            }
           

            chomp ($platform_os);

            chomp ($platform_os_version);

            if (! $platform_os_version ) {

                            CorFail ("Could not get platform OS version");

            }
 
 

可以看到env.core.pl使用正则表达式s/\nMicrosoft.*\[Version +([0-9]+\.[0-9]+)\..*\]/$1/g来分析Ver的输出结果。如果操作系统为非中文版本或者安装了界面包的情况下,ver命令便有可能输出中文结果,导致脚本出错。虽然可以通过修改系统Locale的方式解决,不过更简单的解决方法显然是直接修改脚本,把$platform_version固定为某个值,比如5.1,修改后代码如下:

            if (Windows()) {

                            # assume 5.1 version because the original code cannot parse the output of ver command correctly in non-English OS

                            $platform_os_version = "5.1";

            } else {

                            $platform_os_version = `uname -r`;

                            # we keep all fields of the version number

                            if (! ($platform_os_version =~ s/^[^0-9]*([0-9.]+).*$/$1/s)) {

                                            $platform_os_version = "";

                            }
            }
           

            chomp ($platform_os);

            chomp ($platform_os_version);

            if (! $platform_os_version ) {

                            CorFail ("Could not get platform OS version");

            }
 
 

这里有一个已经修改好的env.core.pl (放在我的Windows Live Skydrive账户里面),有需要的朋友可以点击下载,然后覆盖SSCLI20目录下的env.core.pl即可。

上一篇:PHP使用zlib扩展实现页面GZIP压缩输出
下一篇:构建支持Master/Slave读写分离的数据库操作类
  • 网友评论:
  • 查看所有评论
  • 我要发表评论
您的网名:
留言主题:
你要发表的内容:

 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 发布软件 | 帮助中心 | 源码论坛

Copyright © 2005-2007 CodePub.Com  程序支持:木翼  滇ICP备05005971号