|
|
can't build a .net form in c#
Posted: 08 Feb 08 10:28 AM
|
I'm having trouble creating a .net extension for slx. It is a windows form and when it is created there are three files automatically created. Here is the code from Form1.cs:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Sage.SalesLogix.NetExtensions;
namespace WinTest { public partial class Form1 : Sage.SalesLogix.NetExtensions.IRunnable { private Sage.SalesLogix.NetExtensions.SalesLogix.ISlxApplication _SlxApplication;
public void Initialize(Sage.SalesLogix.NetExtensions.SalesLogix.ISlxApplication SlxApplication, Sage.SalesLogix.NetExtensions.Licensing.ILicenseKeyManager LicenseKeyManager) { _SlxApplication = SlxApplication; }
public object Run(object[] Args) { return null; } } }
Here is the code from Form1.Designer.cs
namespace WinTest { partial class Form1 : Sage.SalesLogix.NetExtensions.IRunnable { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null;
/// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
#region Windows Form Designer generated code
/// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Text = "Form1"; }
#endregion } }
Here is the code from Program.cs:
using System; using System.Collections.Generic; using System.Windows.Forms;
namespace WinTest { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }
I keep getting the following error: WinTest.Form1.Dispose(bool): no suitable method found to override
I'm not sure what i'm doing wrong, can anyone please help?
|
|
|
|
Re: can't build a .net form in c#
Posted: 08 Feb 08 10:45 AM
|
You've changed the form's base class from System.Windows.Forms.Form to Sage.SalesLogix.NetExtensions.IRunnable. You still need to inherit from the Form base class but you can also implement the IRunnable interface. As it is now, you've changed this so it is no longer a form, but it is still attempting to override Form class methods.
Change the class to this:
public partial class Form1 : Form, Sage.SalesLogix.NetExtensions.IRunnable { //... }
Make sense? |
|
|
|
Re: can't build a .net form in c#
Posted: 08 Feb 08 11:20 AM
|
Yes, that makes sense and now it compiles. I'm now having the problem of launching it from slx. I added a nav bar button to launch it and here is the code:
option explicit
sub Main
Dim ext ext = Application.Managed.Create("WinApp","WinApp.Form1") Application.Managed.Run ext Application.Managed.Destroy ext
end sub
where WinApp is the name of the solution and Form1 is where the Run method is placed. |
|
|
| |
|
Re: can't build a .net form in c#
Posted: 08 Feb 08 12:11 PM
|
Originally posted by vaughn poulson
If i remove the Application.Managed.Destroy ext it will work. Do i really need to include that? |
|
That is because you're opening the form as a non-modal form so it is still open when you destroy it. At some point you'd need to destroy it or you'll be creating a memory leak. Or you could open the form as a modal form, then it won't get to the destroy line until after it closes.
|
|
|
| |
|
Re: can't build a .net form in c#
Posted: 08 Feb 08 2:54 PM
|
Originally posted by vaughn poulson
I'm new to slx. How do you open the form as a modal form? |
|
Not really a SLX thing, a C# thing. Somewhere in your C# code you're showing the form, right? You'll want to ShowDialog instead of just show. What I usually do is have a class in my extension that get's loaded from IRunnable and then that calls ShowDialog on my form - both the class and the form are in the same DLL that I add to SLX.
-Ryan |
|
|
|
Re: can't build a .net form in c#
Posted: 09 Feb 08 8:16 AM
|
It looks as if you are building a .net C# application (.exe) for your project based on the files you created. You should not have the Main class that 'Enables styles' and adds Form1 to the application. You start off by creating a .net class library.
You add a single class that implements IRunnable. This is your entry point into showing your form. Now there are 2 ways to tackle your form showing need. 1) in the Run method do
Form1 myForm = new Form1(); myForm.ShowDialog();
- or -
2) Have the run class inherit from System.ComponentModel.Component and make sure that your assembly is COM visible. This can be set in project properties. You then can add methods to your class that can be called from SalesLogix directly
public void ShowAccountExtensionForm() { AccountExtForm form = new AccountExtForm(); form.ShowDialog(); }
in SLX VBScript
dim guid dim obj
guid = Application.Managed.Create(...) set obj = Application.Managed.Run(guid, nothing) obj.ShowAccountExtensionForm()
Does this make sense?
|
|
|
|