Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:44:57+00:00 2026-06-05T17:44:57+00:00

Interesting problem I ran into recently: I implemented a Stream class (a wrapping stream

  • 0

Interesting problem I ran into recently:

I implemented a Stream class (a wrapping stream for a custom streaming pipeline component) and some later testing had my pipeline throwing an exception. The exception was thrown from a call to Seek which I had hardcoded to throw a NotImplementedException due to my stream being a forward-only, non-writable stream implementation (CanSeek and CanWrite returning false, Position:set throwing an exception, nothing unusual). The call to Seek was coming from unmanaged code, so I couldn’t really debug into it too much. All I could really tell was that Seek was being called on my Stream implementation even though I had CanSeek returning false and the user wasn’t even checking CanSeek.

What’s up with that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:44:58+00:00Added an answer on June 5, 2026 at 5:44 pm

    All the answers were found here: Implementing a Seek Method in a Managed Streaming Pipeline Component

    It turns out that way back when, there was no Position property. So the way to get the current position of the stream pointer was to call Seek( 0, SeekOrigin.Current );

    Fascinating. The old new thing again.

    That page gave the Seek implementation required:

    override public long Seek(long offset, SeekOrigin origin)
    {
       long pos = -1;
    
       switch(origin)
       {
          case SeekOrigin.Begin :
             pos = offset;
             break;
          case SeekOrigin.Current :
             pos = Position + offset;
             break;
          case SeekOrigin.End :
             break;
       }
    
       // We generally disallow seeking of the stream
       // However, in unmanaged code, many people use Seek(0,CURR) to retrieve    // the current position
       // Special case (that is, if Seek does not change position, do not 
       // throw an exception)
       if (pos==Position)
       {
          return pos;
       }
       else
       {
          throw new NotSupportedException("ForwardOnlyEventingReadStream does not support Seek()");
       }
    }
    

    And that was the entire solution. Yay!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into an interesting problem. I have a MySQL database that contains some
I ran into an interesting problem at work today. I got a request to
I ran into an interesting (?) problem in the YUI rich edit demo on
I ran into an interesting problem. On my site, i swap out content dynamically
Ran into a interesting little problem. I was writing a method to filter an
An interesting problem I ran into today: what is the fastest way to count
I'm currently building a simple ecommerce site and have ran into an interesting problem.
Ran into an interesting problem with a MySQL table I was building as a
today I ran into a very interesting problem, which I was luckily able to
I ran into an interesting iOS problem today involving a CATiledLayer. This only happend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.