CodeDOM: Warning at compilation RRS feed

  • Question


    I am working with codedom in .NET 2.0. But I am getting following warning during compilation. Can somebody tell me how to get rid of this?


    Compiler Warning

    'System.CodeDom.Compiler.CodeDomProvider.CreateGenerator()' is obsolete: 'Callers should not use the ICodeGenerator interface and should instead use the methods directly on the CodeDomProvider class. Those inheriting from CodeDomProvider must still implement this interface, and should exclude this warning or also obsolete this method.'


    Tuesday, April 17, 2007 1:01 PM


  • If you want a C# provider, do not use CreateGenerator, but create a CodeDomProvider:
    CodeDomProvider p =  new Microsoft.CSharp.CSharpCodeProvider();
    And then use it. For example p.CompileAssemblyFromDom(...) or p.GenerateCodeFromCompileUnit(...).

    For the VB it is the same.

    Tuesday, April 17, 2007 1:20 PM