今天在用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. js获取智能机浏览器版本信息

    <!DOCTYPE html><html> <head>        <meta charset="UTF-8">         ...

  2. Android四大组件之Activity详解

    一.Activity的概要说明 我看过Activity的源码,Activity类注释大概是这样解释的:几乎所有的Activity都是与用户交互用的,我想用了一个几乎的意思应该是排除一些纯展示界面吧,因 ...

  3. Ubuntu_16.04_Lamp

    Ubuntu_16.04安装Lamp开发环境 目录 安装Apache2 安装php5 安装mysql-server 安装php5-mysql(php使用mysql服务,包括mysql,mysqli,m ...

  4. iOS实践03

    主要目标:版本新特性界面,新浪授权界面(登录界面)的处理 任务基本完成了,基本的框架也就到这了,接下来的应该是首页获取微博了. 1.版本新特性,可以单独作为一个model,写完之加入到项目中.我们新建 ...

  5. 如何在内存中压缩并加密ZIP

    项目中遇到了一个问题,考虑到安全原因,需要将文件以二进制数据的方式打包成压缩文件,并且这个压缩文件是有密码的. 去Google上找了些API,下载来看了下,琢磨出了以下方法 首先放API: <! ...

  6. Maven Spring JUnit 在Maven Clean Install时报

    问题: Maven Clean Install时, 遇到报错package org.junit does not exist 明显, Unit Test在Compile阶段就被检查了. 而POM.xm ...

  7. 5.7.1.2 eval() 方法

    现在我们介绍最后一个方法,这大概是ECMAScript语言中最强大的一个方法:eval().eval()方法就想一个完整的ECMAScript解析器,它只接受一个参数,即要执行的ECMAScript( ...

  8. (iOS)推送常见问题

    1.为什么启动的时候出现 Did Fail To Register For Remote Notifications With Error的错误程序运行的时候出现下面的错误信息: did Fail T ...

  9. js数组对象常用方法小结

    ~~~数组添加元素后一般返回数组的新长度 如: push(ele1[,ele2...]), unshift(ele1[,ele2...]) ~~~数组删除元素后一般返回被删除的元素 如: pop() ...

  10. Windows下配置PHP

    啥也不说了,照着这两篇做,OK 1. windows下apache+php+mysql 环境配置方法 详细出处参考:http://www.jb51.net/article/30128.htm 2.ht ...