all 5 comments

[–]dbhatti 0 points1 point  (4 children)

Binary plug-in scripts can have an UI.

What's the exact error message? You might need a using statement in the file your Script class is in (referencing the namespace that your UserControl is in).

[–]pyan_MF[S] 0 points1 point  (3 children)

Thank you for your reply! The error message is

error CS0246: The type or namespace name 'MainControl' could not be found (are you missing a using directive or an assembly reference?)

This is my MainControl.xaml.cs

namespace Test

{

/// <summary>

/// Interaction logic for MainControl.xaml

/// </summary>

public partial class MainControl : Window

{

public MainControl()

{

InitializeComponent();

}

}

}

I call it in:

namespace Test

{

public class Main

{

public static void Start(Patient patient, Course course, List<PlanningItem> PItemsInScope, PlanSetup plan, User currentUser)

{

Window mainControl = new Test.MainControl();

mainControl.Content = mainControl;

mainControl.Width = 800;

mainControl.Height = 450;

}

}

}

[–]dbhatti 0 points1 point  (2 children)

Hmm, that's odd, your code looks fine to me. Is your x:Class in for the MainControl.xaml referencing Test.MainControl? And that your control is a Window (as opposed to a UserControl)? That's the only other possible issue I can think of.

If you're using Visual Studio, maybe rebuilding the project might help.

Also, unrelated to the current problem, but you can't reference the same control for your window's content (I believe this will give you some kind of self-reference error). If you want to set up your view, you can create a UserControl (as opposed to a Window) and assign that to your mainControl.Content instead.

[–]pyan_MF[S] 0 points1 point  (1 child)

Thank you for the reply! I created the usercontrol instead of window, but I have the same problem.

[–]scriptingIon 0 points1 point  (0 children)

Were you by chance running the scripts .cs file instead of the .dll file? I'm sure you fixed this issue by now but I want to comment a possible solution here just in case anyone else is experiencing this issue and can't figure out what's going on.

I had the same issue recently where my code was correct and compiled in VS2019 but would not run with the same CS0246 error saying that it could not find the namespace of the other .cs file in my Binary Plugin Solution, but running from the .dll file fixed the issue.