This would be difficult/impractical/impossible for two primary reasons:
Speed: Sound cancellation must capture, calculate the cancellation and generate the cancellation very fast, probably with no more than a 1 millisecond delay. That's going to be hard to do with managed code.
Phase Positioning: The proper cancellation phase for any sound/noise is entirely dependent on the precise distance relationship between the microphone, the speakers and your ears. The first two stay fixed, but your ears tend to go wherever you head goes, which your code has no way of knowing about. (this is one big reason why noise cancellation works so well with headphones, but not for anything else).