今天在用DicomFile.Open(Stream s)这个接口时,遇到一个异常:
     DicomIoException: Requested 132 bytes past end of fixed length stream.
详细原因我们看下源代码就非常清楚:
public bool Require(uint count, ByteSourceCallback callback, object state) {
lock (_lock) {
if ((_stream.Length - _stream.Position) >= count)
return true;
throw new DicomIoException("Requested {0} bytes past end of fixed length stream.", count);
}
}
当时的Stream的Position位于流末尾,即Length-Position等于0, 因此抛出这个异常。
解决的方法非常easy:
首先把Stream定位到DICOM的起始位置。
相似代码例如以下:
  var stream = new MemoryStream();
            using (var f = File.Open(@"1.2.156.112605.75006881735343.1369658682.4.4.1.dcm", FileMode.Open))
            {
                f.CopyTo(stream);
            }
            stream.Seek(0, SeekOrigin.Begin);
            var df = Dicom.DicomFile.Open(stream);

DicomIoException: Requested 132 bytes past end of fixed length stream.的更多相关文章

  1. Zabbix Server宕机报“__zbx_mem_malloc(): out of memory (requested 96 bytes)”

    早上登录Zabbix的时候,发现其提示"Zabbix server is not running: the information displayed may not be current& ...

  2. An universal algorithm design of fixed length substring locating

         An universal algorithm design of fixed length substring locating Stringlocating is a very commo ...

  3. Bytes to be written to the stream exceed the Content-Length bytes size specified 解决方法

    context.Response.ContentType = encode;                using (StreamWriter writer = new StreamWriter( ...

  4. (转)HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the Content-Length bytes size specified.”错误

    from:http://www.cnblogs.com/Gildor/archive/2010/12/13/1904060.html HttpWebRequest以UTF-8编码写入内容时发生“Byt ...

  5. 【原创】开源Math.NET基础数学类库使用(03)C#解析Matlab的mat格式

                   本博客所有文章分类的总目录:[总目录]本博客博文总目录-实时更新  开源Math.NET基础数学类库使用总目录:[目录]开源Math.NET基础数学类库使用总目录 前言 ...

  6. 【Remoting】.Net remoting方法实现简单的在线升级(上篇:更新文件)

    一.前言:       最近做一个简单的在线升级Demo,使用了微软较早的.Net Remoting技术来练手. 简单的思路就是在服务器配置一个Remoting对象,然后在客户端来执行Remoting ...

  7. 开源Math.NET基础数学类库使用(03)C#解析Matlab的mat格式

    原文:[原创]开源Math.NET基础数学类库使用(03)C#解析Matlab的mat格式 开源Math.NET基础数学类库使用系列文章总目录:   1.开源.NET基础数学计算组件Math.NET( ...

  8. Stream/Bytes[]/Image对象相互转化

    Stream/Bytes[]/Image对象相互转化 Stream转Byte数组.Image转Byte数组.文件转Stream等 /// <summary> /// 将 Stream 转成 ...

  9. sream bytes[] img相互转换

    /// <summary> /// 将 Stream 转成 byte[] /// </summary> /// <param name="stream" ...

随机推荐

  1. IE7下浮动元素的内容自动换行的BUG解决方法

    有时候我们想写个浮动得到这样的效果: 代码: <!doctype html> <html> <head> <meta charset="utf-8& ...

  2. zoj 1453 Stripies

    /* 根据题意:不难看出,要是整个方程式最小,那么应该大的数先结合,小的数后结合.先排序然后结合(贪心) */ #include<stdio.h> #include<stdlib.h ...

  3. string s = HttpContext.Current.Server.MapPath("");

    string s = HttpContext.Current.Server.MapPath(""); 获取当前文件夹路径 而后用相对路径读取图片

  4. 一般处理程序在VS2012中打开问题

    问题:如果你用vs2012建立的一个一般处理程序,运行查看是,出现这样的界面 原因:VS2012默认使用IIS Web服务器,而不是Visual Studio开发服务器,基于安全考虑IIS默认不允许浏 ...

  5. 5.5 Function类型

    说起来ECMAScript中上面最有意思,我想那莫过于函数了,有意思的根源,则在于函数实际上是对象.每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此 ...

  6. Servlet运行过程详解

    比如,在浏览器地址栏输入http://ip:port/web01/hello step1,浏览器依据ip,port建立与servlet容器(容器同时也是一个简单的web服务器)之间的连接. step2 ...

  7. 神奇的魔法数字0x61c88647

    来源JDK源码,产生的数字分布很均匀 用法代码如下. # -*- coding: utf-8 -*- HASH_INCREMENT = 0x61c88647 def magic_hash(n): fo ...

  8. IAR Embedded Workbench for ARM 6.50.6 & 6.60.1 破解补丁

    IAR EWARM 6.50.6 & 6.60.1 破解 破解原理和方法见:http://blog.csdn.net/chivalrys/article/details/8564568 IAR ...

  9. android下文件下载

    public static void downFile(final String url){ new Thread(){ public void run(){ FileOutputStream os= ...

  10. 定制ToolChain for ARM

    **************************************************************************编写:王卫无,北京讯业互联科技有限公司版本号:V1. ...