c# - Is it possible to throw a MessageQueueException? -


i using mock object in rhinomocks represent class makes calls messagequeue.getpublicqueues. want simulate exception thrown when message queueing operating in workgroup mode, messagequeueexception, ensure catching exception correctly

the messagequeueexception has no public constructor, standard protected constructor exception. there appropriate way throw exception mock object / expect.call statement?

reflection can break accessibility rulez. will void warranty, .net update can break code. try this:

using system.reflection; using system.messaging; ...         type t = typeof(messagequeueexception);         constructorinfo ci = t.getconstructor(bindingflags.nonpublic | bindingflags.instance,            null, new type[] { typeof(int) }, null);         messagequeueexception ex = (messagequeueexception)ci.invoke(new object[] { 911 });         throw ex; 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -