Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invoking WPF from CsScript..
#1
Hi - I'm having what I believe to be DLL loading issues when trying to run a simple WPF example (directly copied from http://www.csscript.net/help/wpf.html. I've used CsScript for other code that either interfaced with other programs or invoked web services - is there a problem invoking WPF or do I have a simple coding issue? In the past the main issue with assembly references were resolved by adding the right path and DLL names to the options string. And yes - I haven't figured out where to load the XAML from yet but I figured I'd do that after the program successfully loaded. Any help appreciated.

Here's the output:
Code:
Copy      Help
64 bit path
Error (RT) in WPFTest:  0x80131600,
    WPFTest(29,14): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
    WPFTest(31,42): error CS0234: The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)
    WPFTest(37,30): error CS0246: The type or namespace name 'RoutedEventArgs' could not be found (are you missing a using directive or an assembly reference?).    ?

And the function itself:

Function WPFTest
Code:
Copy      Help
;; WPF test


str options

if (_win64 == 1)
,out "64 bit path"
,;; 64 bit machine
,options = "searchDirs=C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0;[]references= PresentationFramework.dll;PresentationCore.dll;WindowsBase.dll;System.Windows.Forms.dll;System.Windows.Presentation.dll;System.Core.dll;System.Xml.dll;System.ServiceModel.Web.dll;System.Runtime.Remoting.dll"
else
,out "32 bit path"
,;; 32 bit machine
,
,options = "searchDirs=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client\[]references= PresentationFramework.dll;PresentationCore.dll;WindowsBase.dll;System.Windows.Forms.dll;System.Windows.Presentation.dll;System.Core.dll;System.Xml.dll;System.ServiceModel.Web.dll;System.Runtime.Remoting.dll"
,
CsScript x.AddCode("");;


x.SetOptions(options)
IDispatch o = x.CreateObject("MainWindow");

#ret

//css_inc Hello.xaml;
//css_ref WindowsBase;
//css_ref PresentationCore;
//css_ref PresentationFramework;
using System;
using System.Windows;

public partial class MainWindow : System.Windows.Window
{
,public MainWindow()
,{
,,InitializeComponent();
,}
,void OnClick(object sender, RoutedEventArgs e)
,{
,,MessageBox.Show("Hello World!");
,}

,[STAThread]
,public static void Main()
,{
,,MainWindow wnd = new MainWindow();
,,wnd.ShowDialog();
,}
}
#2
SetOptions must be before AddCode.
CsScript x.SetOptions(options)
x.AddCode("")
Then I get error InitializeComponent.
I'm not familiar with WPF, cannot help much.


Forum Jump:


Users browsing this thread: 1 Guest(s)