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 932221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:37:51+00:00 2026-05-15T20:37:51+00:00

Now that .NET CLR 4.0 supports side by side (SxS) operation it should now

  • 0

Now that .NET CLR 4.0 supports side by side (SxS) operation it should now be possible to write shell
extensions in managed code. I have attempted this and successfully coded a Property Handler
that implements IPropertyStore, IInitializeWithStream and IPropertyStoreCapabilities.

The handler
works fine and is called as expected when browsing files via the explorer. It also works fine in displaying the
custom properties in the preview panel and the file properties “detail” panel.

However, when I attempt to
edit a property in the preview panel, and then click “Save” I get a “File In Use” error saying that
the file is open in Windows Explorer.

A few tidbits:

  1. When explorer calls IInitializeWithStream.Initialize the STGM property is set to STGM_SHARE_DENY_WRITE.
  2. And at no point did explorer call IPropertyStore.SetValue or IPropertyStore.Commit.
  3. I see repeated calls to my handler on different threads for the same file properties.

So what do I need to change (or set in the registery) to get the property save to work?

Update:

Thanks to Ben I’ve got it working. The “difficult part” (at least for me) was understanding that COM interop would never call Dispose or Finalize on my PropertyHandler. This was leaving the files I processed open till the GC ran.

Fortunately, the “property handler protocol” works such that when IInitializeWithSream.Initialize() is called for a ReadValue() the streamMode is ReadOnly, and when it is called for a SetValue() the streamMode is ReadWrite and Commit() will be called at the end.

int IInitializeWithStream.Initialize( IStream stream, uint grfMode )
{
    _stream = stream;
    _streamMode = (Stgm)grfMode;

    Load();

    // We release here cause if this is a read operation we won't get called back, 
    // and our finializer isn't called. 
    if ( ( _streamMode & Stgm.ReadWrite ) != Stgm.ReadWrite )
    {
        Marshal.ReleaseComObject( _stream );
        _stream = null;
    }
    return HResult.S_OK;
}

int IPropertyStore.Commit()
{
    bool result = false;

    if ( _stream != null )
    {
        result = WriteStream( _stream );
        Marshal.ReleaseComObject( _stream );
        _stream = null;
    }

    return result ? HResult.S_OK : HResult.E_FAIL;
}
  • 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-05-15T20:37:52+00:00Added an answer on May 15, 2026 at 8:37 pm

    Yes, you have to AddRef() the stream to keep it open and to keep the reference alive correctly.

    Note that the indexer will use your property handler to open the file as well. So if you leak the stream object, the file will remain open. You can use the sysinternals procexp to tell what process has the file open, or procmon to tell what calls and parameters it used.

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

Sidebar

Related Questions

I have a code library that works in ASP.NET, the SQL CLR, and stand-alone
Now that ASP.NET MVC 2 is out , I tried to install it on
I know that .NET assembly is self-descriptive because of the metadata. Now suppose I
I'm investigating ASP.NET MVC now and noticed that in ASP.NET MVC application, which is
I have application in VB.net that have two different form (Form1 and Form2). Now
We are developing an ERP using ASP.Net and C#.Net. Now in that, I want
In the .net 3.5 project that I am working on right now, I was
I am learning ASP.NET MVC now a days and I have found that most
I made a simple .NET WCF wsDualHttpBinding that does callback to client. Now I
I have a two column layout: http://jsfiddle.net/KqQ42/1/ Now I would like that the left

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.