• Upgrade your Internet Experience
  • Sign in
  • Microsoft.com
  • United States (English)
    Brasil (Português)Česká republika (Čeština)Deutschland (Deutsch)España (Español)France (Français)Italia (Italiano)Россия (Русский)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語)香港特别行政區 (中文)
 
 
Visual Studio Developer Center
 
 
Home
 
 
Library
 
 
Learn
 
 
Download
 
 
Support
 
 
Community
 
 
Forums
 
 
 
Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > CoRegisterMessageFilter doesn't appear to be registering the message filter.
Ask a questionAsk a question
Search Forums:
  • Search Visual Studio Tools for Office Forum Search Visual Studio Tools for Office Forum
  • Search All Visual Studio Forums Search All Visual Studio Forums
  • Search All MSDN Forums Search All MSDN Forums
 

AnswerCoRegisterMessageFilter doesn't appear to be registering the message filter.

  • Monday, October 27, 2008 5:34 PMejm78 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    I am trying to implement a custom COM message filter using the code referenced here (http://msdn.microsoft.com/en-us/library/ms228772(VS.80).aspx).  However, the CoRegisterMessageFilter call in MessageFilter.Register returns a result of -2147467231.  According to the documentation, the only valid return results are 0 and 1 for S_OK and S_FALSE.  If I let the code run, I am still getting the RPC server is busy error, but the retry code is never called.  This leads me to believe that the message filter is not getting registered.  Does anybody have any idea what this return result means?

    - IDE: Visual Studio 2008
    - Framework: .Net 3.5 SP1
    - Language: VB.net
    - I'm not actually using VSTO, but instead accessing office throught the PIA's.
    - I am calling register before instantiating a PowerPoint.Application object and revoking it when I am done.

    I am not sure what other information will be needed.  I didn't post any code because I used an exact copy of what is in the document I referenced above.  If you need any other info, please just ask.

    Thanks in advance for all your time!
    Eric.
    • ReplyReply
    • QuoteQuote
     

Answers

  • Monday, October 27, 2008 6:32 PMGeoff Darst - MSFTAnswererUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Vote As Helpful
    1
    Hi,

    You are getting a CO_E_NOT_SUPPORTED error.  Most likely that means you are calling CoRegisterMessageFilter from a thread that is in the Multi-Threaded-Apartment (MTA).  MessageFilters are only supported on Single-Threaded-Apartment (STA) threads.

    Sincerely,

    Geoff Darst
    Microsoft VSTO Team
    • Marked As Answer byGeoff Darst - MSFTAnswererMonday, October 27, 2008 6:32 PM
    •  
    • ReplyReply
    • QuoteQuote
     

All Replies

  • Monday, October 27, 2008 7:33 PMejm78 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Vote As Helpful
    0
    Geoff - Thank you for the quick reply!  You are absolutely correct.  Although I knew that it had to be running on an STA thread, I didn't realize that my NUnit tests (yes, I am planning on migrating to MS Test) were running in MTA!

    I added a check when registering the MessageFilter that throws an exception if the current thread is not STA.  This is helpful because it will block it right from the start, rather than allowing to code to execute while not using the custom MessageFilter.  Just thought I would add that for anyone else running into a similar problem.

    Thank you so much for your help!

    Eric.
    • ReplyReply
    • QuoteQuote
     
Need Help with Forums? (FAQ)
 
© 2009 Microsoft Corporation. All rights reserved.
Terms of Use
|
Trademarks
|
Privacy Statement