Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Compile in memory with VS2005 - Help!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pamelafluente@libero.it - 03 Mar 2006 17:09 GMT
Hi I am adjusting a project for VS2005. I had this code which worked
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?
tommaso.gastaldi@uniroma1.it - 04 Mar 2006 02:51 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.