Writing to Output window from a c++ called by C#
See the question and my original answer on StackOverflowYou can use the OutputDebugString function.
If you want to support variable arguments (like printf), you need to add a bit more code as in this answer: How do you create a debug only function that takes a variable argument list? Like printf()