Easy way to make a com DLL in c#?
Comments
-
Thanks.
I have still problems. If I use AutoDual for the class, all is ok. In .tlb file there are all method etc. If I do not use AutoDual there is only the class without members. Never the Interface... :-s
May be that problem is that the class is inherited from the Form class and is using some Interface (and not only the interface without inheritating...)0 -
As promised, I tried your code in Visual Studio 2005.
It turns out that we both overlooked one little keyword 'public'... :oops: :!:public interface IWrapperClass
Without making your interface public, Navision will never be able to determine the correct interface of the class when the ClassInterfaceType = None.
Remember, you should set the InterfaceType to ComInterfaceType.InterfaceIsIDispatch (which is default)A good programmer makes al the right mistakes
My blog0 -
kine wrote:How can I unregister the .net interop DLL? (I know only the way of regsvr32 but this is not the correct one in this case)
One other (much simplier way) to unregister: just remove the "Register for COM Interop" checkmark in the project properties and rebuild the project. This will unregister the dll for COM.A good programmer makes al the right mistakes
My blog0 -
It is working now. Final version:
Interface:[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] [ComVisible(true)] [GuidAttribute("some GUID")] public interface IMyInerface { [DispId(1)] void AboutBox(); [DispId(2)] short SomeProperty { get; set; } ...
Class:[ClassInterface(ClassInterfaceType.None)] [ComVisible(true)] [GuidAttribute("another GUID")] public partial class MyClass : SomeOtherClass, IMyInterface { public void AboutBox() { ... } ...
0 -
How do you expose attributes of a com class? I can expose my methods but not my attributes..
EDIT: God damn, I forgot public ](*,)Navision developer0 -
Hi,
I am trying to do it without Visual Studio, because that costs money you knowwith the free SharpDevelop IDE. The problem is that this IDE does not provide a project option for registering as a COM object.
So what I am trying to do is the following:
code taken from an example mentioned earlier in this topicusing System; using System.Runtime.InteropServices; [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface GeneralNavTest { int Add2Numbers(int a, int b); } [ClassInterface(ClassInterfaceType.AutoDual)] public class NavTest : GeneralNavTest { public NavTest() { } public int Add2Numbers(int a, int b) { return(a+b); } }
and then I copy it to the Navi client folder, and then"c:\Windows\Microsoft.NET\Framework\V1.1.4322\RegAsm.exe" "c:\Program Files\Microsoft Business Solutions-Navision\Client\navtest2.dll" /tlb:navtest2.tlb
what happens is that the registration is successful, but it does not appear in Navision under Custom Controls in Tools menu.
Any ideas?
Do It Yourself is they key. Standard code might work - your code surely works.0 -
You have no
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] [ComVisible(true)]
lines in your example...(and others)0 -
In order to use a C# dll in Navision the dll must have a strong name. U need a keypair. U can create one using sn.exe. There should also be an interface in you .net application with the public methods..
Once the dll is compiled with the key, you need to put it in the assembly folder and register it using regasm.. Then you're set0 -
Shenpen wrote:Hi,
I am trying to do it without Visual Studio, because that costs money you knowwith the free SharpDevelop IDE. The problem is that this IDE does not provide a project option for registering as a COM object.
So what I am trying to do is the following:
code taken from an example mentioned earlier in this topic
what happens is that the registration is successful, but it does not appear in Navision under Custom Controls in Tools menu.
Any ideas?
I just use that code and then put "com visible" and "register for com interop" attribute to TRUE and then it registers it for Navision automatically.Navision developer0
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