Creating an automation with event(s)

frankmortensen
Member Posts: 42
Hi
I am trying to create an automation (class library) in C#.
The automation has one event.
Can someone please tell me how an automation needs to look like in order for Navision to be able to see the event and automatically generate the trigger for the event that my automation provides (MyAutomation::MyEvent...).
Here's what I have so far:
using System;
using System.Runtime.InteropServices;
public delegate void MyDelegate();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IMyClass
{
event MyDelegate MyEvent;
}
[ClassInterface(ClassInterfaceType.None)]
public class MyClass : IMyClass
{
public event MyDelegate MyEvent;
public void TriggerTheEvent()
{
if (MyEvent != null)
MyEvent();
}
}
/Frank Mortensen
I am trying to create an automation (class library) in C#.
The automation has one event.
Can someone please tell me how an automation needs to look like in order for Navision to be able to see the event and automatically generate the trigger for the event that my automation provides (MyAutomation::MyEvent...).
Here's what I have so far:
using System;
using System.Runtime.InteropServices;
public delegate void MyDelegate();
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IMyClass
{
event MyDelegate MyEvent;
}
[ClassInterface(ClassInterfaceType.None)]
public class MyClass : IMyClass
{
public event MyDelegate MyEvent;
public void TriggerTheEvent()
{
if (MyEvent != null)
MyEvent();
}
}
/Frank Mortensen
0
Comments
-
I think RaiseEvent is the command you need.
Try this
http://www.mibuso.com/forum/viewtopic.php?t=81590 -
Thanks for the quick reply. The 3rd line from the bottom is the line that raises the event (in C#). But I haven't even come as far as trying to raise any events as Navision doesn't recognise my event and therefor doesn't create the event trigger inside Navision. (Single instance and with events are set to yes).
/Frank0 -
Setting the WithEvents property to yes should do the trick automatically, and the event trigger should automatically appear when you close the variables window.
What I did see a few times is when I forgot to set the property, saved the codeunit and discovered that it wasn't there. When I then set the property, it did not appear. I then had to remove the variable, save and close the codeunit, re-open it and create the variable with events. It's a pain in the neck sometimes, but those are things you should try before questioning your C# code.0 -
You need to make the event public in the interface...0
-
I am pretty sure that the Navision side is working.
I am unsure about the C# code though.
How can I set can I set an event public (or private) inside an interface?
/Frank0 -
Do any of you guys have a the source code for c-sharp project that I might have a look at?
/Frank0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions