How to mole System.dll

by Donovan Brown 15. December 2011 14:07


I get “no suitable method found to override” errors when I mole system.dll.


Modify the System.moles file in your project and exclude everything except the types you are trying to mole.


I was trying to mole the SerialPort class in System.IO.Ports. After adding the mole for System.dll I began to get “no suitable method found to override” errors.  To resolve this issue I simply double clicked the System.moles file to open it in my IDE.  Then I modified the file so that moles were created only for the types under System.IO.  Change System.moles from this:

<Moles xmlns="">
  <Assembly Name="System" />

to this:

<Moles xmlns="">
   <Assembly Name="System" />
         <Clear />
         <Add Namespace="System.IO!" />

Tags: , , ,


About the author

My name is Donovan Brown and I am a Technology Specialist for DevTools with Microsoft with a background in application development.  I also run one of the Nation’s fastest growing online registration sites for motorsports events  When I am not writing software I race cars for fun. has given me the opportunity to combine my two passions writing software and racing cars.


Month List