|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Compile in memory with VS2005 - Help!!fine in VS2003 and now I am having a warning: Warning 1 'Public Overrides Function CreateCompiler() As System.CodeDom.Compiler.ICodeCompiler' is obsolete: 'Callers should not use the ICodeCompiler interface and should instead use the methods directly on the CodeDomProvider class. Could you, please, suggest the code changes to adapt this code to VS2005 (any language will be fine). If appropriate, return result in a CompilerResults object, as in my code, or equivalent, please. My VB2003 "OBSOLETE" code: ------------------------------------------------------ Public MyObjectCode As String Public ICodeCompiler As ICodeCompiler Public CompilerParameters As CompilerParameters Public CompilerResults As CompilerResults Dim VBCodeProvider As New VBCodeProvider Me.ICodeCompiler = VBCodeProvider.CreateCompiler() Me.CompilerParameters = New CompilerParameters With CompilerParameters .IncludeDebugInformation = False .GenerateInMemory = True .GenerateExecutable = False '... more parameters here End With Me.CompilerResults = Me.ICodeCompiler.CompileAssemblyFromSource(Me.CompilerParameters, Me.MyObjectCode) '------------------------------------------------------------------------------------- Thank you very much in advance! -Pamela PS. As side question, does this warning mean that there is no more need to instantiate a compiler, because we can use one which is already instantiated internally? It's not complicate. This, for instance, would do it (adjust
declarations): Public MyVBCodeProvider As System.CodeDom.Compiler.CodeDomProvider = New Microsoft.VisualBasic.VBCodeProvider Me.CompilerResults = MyVBCodeProvider.CompileAssemblyFromSource(Me.CompilerParameters, Me.MyObjectCode) where Me.MyObjectCode is for instance the code of the class being compiled and to be later activated, e.g.: Me.ClassType= CompilerResults.CompiledAssembly.GetType(ClassName) Me.MyInstance= Activator.CreateInstance(Me.ClassType) .... etc. VS2005 is a great improvement. Apart the spectacular IDE, there are a lot of things greatly improved wherever in the language (using, etc.). My preferred are those in the area of hashtables (IEqualityComparer, etc.), that had some problems in the 2003... ;-) Best programming tool ever, now! -tom |
|||||||||||||||||||||||