In my first C# console application I want to avoid COM problems and therefore I'm registering the IOleMessageFilter to handle any threading errors.
Well this wouldn't be a question without the problem part so here we go:
public static void Register()
IOleMessageFilter newFilter = new MessageFilter();
IOleMessageFilter oldFilter = null;
int test = CoRegisterMessageFilter(newFilter, out oldFilter);
if (test != 0)
_isRegistered = true;
This never goes past the Debug.Fail, but I can't understand why as the message is not very explanatory by itself:
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
at SysConfig.MessageFilter.Register() in c:\...\MessageFilter.cs:line 42
at SysConfig.DTE.CreateDTE(Boolean ideVisible, Boolean suppressUI, Boolean userControl) in c:\...\DTE.cs:line 50
at SysConfig.Program.SysConfigM(Int32 i) in c:\...\Program.cs:line 163
at SysConfig.Program.SetNumberOfM() in c:\...\Program.cs:line 136
at SysConfig.Program.MenuHandler() in c:\...\Program.cs:line 48
at SysConfig.Program.Main(String args) in c:\...\Program.cs:line 26
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
What could happen?, searching about CoRegisterMessageFilter is very fun as it doesn't show a lot of information...
And... I've just copied the class from an example, and called Register()...
I'm trying to automate Visual Studio, in most cases the program flow works perfectly.
In some other cases it fails during calls to the Visual studio DTE...
In the manual from the manufacturer of the software I'm using they state that I should implement that COM Message Filter and they explain how to do it... Even they provide a sample that I've pasted directly into my code...
Anyone can see what's wrong given the message?
Should I add any dependency or similar thing into my project to get this working?
Being ultra-novice in C# I can't see where to search now...
And I truly would like not to add wait timers everywhere...
Thank you very much for your time and help.