XML Schema Definition (XSD) and the Web Ontology Language (OWL) have been widely used to define programming language independent data types and to conceptualize knowledge. However, writing software that operates on XML instance documents and on ontological knowledge bases still suffers from a lack of compile time support for XSD and OWL. In this paper, a novel compiler framework is presented that facilitates the cooperative usage of external type systems with C#. For the resulting programming language Zhi#, XSD and OWL compiler plug-ins were implemented in order to provide static type checking for constrained atomic value types and ontologies. XSD constraining facets and ontological inference rules could be integrated with host language features such as method overwriting. Zhi# programs are compiled to conventional C# and are interoperable with .NET assemblies.