Options

How to create a Navision dll/ocx in Visual Studio 2005 .NET

timotimo Member Posts: 11
I want to create a Navision Custome Control (OCX or DLL) -> for example one dll which create a "Hello World" massagebox after starting from navision.
I use Visual Studio 2005 .NET. C# is the favorieted language.

Can someone give me a Code example or guide for the dll?
Check out our new NAVonline HelpDesk

Comments

  • Options
    JedrzejTJedrzejT Member Posts: 267
    Imports System.Runtime.InteropServices
    Namespace Something
    <ClassInterface(ClassInterfaceType.AutoDual)> _
    Public Class Starter

    Public Sub SayHello()
    messagebox.show('Hello world')
    End Sub

    End Class
    End Namespace

    in prpreties of solution chose "output type" - class library
    in configuration prop check the "registrer for COM interop"

    Now you can use method of your dll in navision


    Regards
  • Options
    timotimo Member Posts: 11
    sorry but i can't find the option for

    in configuration prop check the "registrer for COM interop"

    can you give me a hind?


    I find it!
    Check out our new NAVonline HelpDesk
  • Options
    timotimo Member Posts: 11
    It don't work.

    I can't import the dll in Navision Custom Controls. Error: OLE Control can't register
    Check out our new NAVonline HelpDesk
  • Options
    rvduurenrvduuren Member Posts: 92
    Try..
    using System;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace DynamicNav
    {
        [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        public interface INavDefault
        {
            // Method
            void HelloWorld();
            int Add2Numbers(int a, int b);
            // Property
            DateTime MyDate { set; get; }
        }
        [ClassInterface(ClassInterfaceType.None)]
        public class NavDefault : INavDefault
        {
            public NavDefault()
            {
            }
            // Method
            public void HelloWorld()
            {
                MessageBox.Show("Hello World");
            }
            public int Add2Numbers(int a, int b)
            {
                return (a + b);
            }
            // Property
            private DateTime allocDate = DateTime.Today;
            public DateTime MyDate
            {
                set { allocDate = value; }
                get { return allocDate; }
            }
        }
    }
    
    In your AssemblyInfo.cs
    [assembly: ComVisible(true)]
    
    ..let me know if it works.

    ..psst. you can't register dotNet components in NAV Custom Controls, use regasm instead..
    Met vriendelijke groet, best regards,

    Rvduuren
  • Options
    FCPFCP Member Posts: 36
    edited 2007-11-17
    I had the same problem, after reading a lot of things trying a lot things, found a simple solution. check it out

    http://valpi.pt/web/valpi.nsf/a9d3838b9 ... enDocument
  • Options
    timotimo Member Posts: 11
    edited 2012-10-17
    @ JedrzejT: Thank you It works, afer register with regasm.exe. But not as Custom Control - as Automation Server. Whats the difference?


    The other Samples i will test tomorrow - thank you all
    Check out our new NAVonline HelpDesk
  • Options
    CenTCenT Member Posts: 12
    Anyone actually able to create a .NET Assembly with events that create eventtriggers in navision when setting the automation property to WithEvents "True"?

    Some sample code could be useful if you have done so in the past.
    Thanks.
  • Options
    tlarsontlarson Member Posts: 27
    With help from Demiliani's posts, as referenced above, I managed to get an Automation Object compiled and working with .Net 3.5 and Visual Studio 2008. To download the full solution sample code for a Hello World example (including a fob file), go to http://adventuresindotnet.blogspot.com/ ... bject.html

    Tim Larson
Sign In or Register to comment.