locked
Code compiled on the fly RRS feed

  • Question

  • Traditional non-wpf allows code on the fly compilation of vb/C# via ICodeCompiler, but as soon as I stick anything remotely WPFy in the code the compiler winces:

     

    If in a dynamic bit of VB I use:

    Imports System.Windows.Controls

     

    I get the message

    "Namespace or type specified in the Imports "System.Windows.Controls" doesn't contain any public member or cannot be  found.

     

    I also get: Reference required to assembly "PresentationFramework" when referencing a remote System.Windows.Controls.TextBox

     

    - how do I make my compiled on the fly snippets WPF-aware?

     

     

    Is it also possible to bundle script and associated xaml dialogs to be compiled on the fly? I would like to be able to issue modular updates without having to reissue full product builds.

     

    I have been able to do on the fly xaml rendering, albeit I am limited in so far as "dynamic" xaml does not let you specify event calls. They have to be managed WITHIN the build application. eg. button Click events. You cannot specify Click="clickme" in the xaml but in the code you add the button.Click = ...

     

     

    Friday, November 16, 2007 6:27 PM

Answers

  • Did you actually add the required reference to the compiler options, as the error message is suggesting you do?

     

    Friday, November 16, 2007 7:49 PM

All replies

  • Did you actually add the required reference to the compiler options, as the error message is suggesting you do?

     

    Friday, November 16, 2007 7:49 PM
  • No - I consider my wrist now well slapped. I'll take a look at the available compiler options...
    Thanks!
    Saturday, November 17, 2007 1:57 PM
  • yes that worked:

     

    {

    ICodeCompiler compiler = new Microsoft.VisualBasic.VBCodeProvider().CreateCompiler();

    CompilerParameters parms = new CompilerParameters();

    CompilerResults results;

    String reference = path;

    // Find reference

    parms.ReferencedAssemblies.Add(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll");

    parms.ReferencedAssemblies.Add(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll");

    parms.ReferencedAssemblies.Add(@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFrameWork.dll");

    ...

     

    (Obviously, the path will not be hardcoded... - oops - I feel another post coming on about getting the Framework path).

     

     

    Monday, November 19, 2007 11:41 AM