今天在用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. sql表连接的几种方式

    这里有两张表TableA和TableB,分别是姓名表和年龄表,用于我们例子的测试数据 TableA id name 1 t1 2 t2 4 t4 TableB id age 1 18 2 20 3 1 ...

  2. Lowest Common Ancestor of a Binary Tree, with Parent Pointer

    Given a binary tree, find the lowest common ancestor of two given nodes in tree. Each node contains ...

  3. 如何实现HTTPSERVER

    Write your own http server author : Kevin Lynx Why write your own? 看这个问题的人证明你知道什么是http server,世界上有很多 ...

  4. php学习笔记(3)

    1.计数器 <?php /* simple access counter for php3 (c)1998 David W. Bettis dbettis@eyeintegrated.com m ...

  5. android-JSON解析

    构建JSON文本 方法1. // 假设现在要创建这样一个json文本 // { // "phone" : ["12345678", "87654321 ...

  6. HDU3966(树链剖分)

    题目:Aragorn's Story 题意:给一棵树,并给定各个点权的值,然后有3种操作: I C1 C2 K: 把C1与C2的路径上的所有点权值加上K D C1 C2 K:把C1与C2的路径上的所有 ...

  7. BZOJ 1008 越狱 (组合数学)

    题解:正难则反,从总数中减去全部相邻不相同的数目就是答案,n*(n-1)^(m-1):第一个房间有n中染色方案,剩下m-1个房间均只有n-1种染色方案,用总数减就是答案. #include <c ...

  8. HDU 1001 Sum Problem

    /* 注意可以是负整数,而且在过程中会超过int,所以要用longlong */ #include <cstdio> int main() { long long n; while (sc ...

  9. HDOJ 1226 超级密码(bfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1226 思路分析:题目要求寻找一串长度不大于500的C进制的密码,且该密码需要为十进制数N的整数倍. & ...

  10. vs2010经常使用快捷键

    调试快捷键 F6: 生成解决方式 Ctrl+F6: 生成当前项目 F7: 查看代码 Shift+F7: 查看窗口设计器 F5: 启动调试 Ctrl+F5: 開始运行(不调试) Shift+F5: 停止 ...