Hi
I am currently playing around with visual studio C# express 2005 beta 2 and want to make a dll that I can use as an automation from within Navision. I have done this sometimes before with VB .net and it was relatively easy because there is a wizard to make the comclass . But how do I do this in C#?
0
Comments
RIS Plus, LLC
I found this:
http://www.codeproject.com/csharp/CSCom ... ect=905084
It seems that is not because i am using a Beta, somehow there a differences between the tools you have on VB.net in comparison to C# .net
So I still need help
http://www.mibuso.com/forum/viewtopic.php?t=6955
Thx for the link, I think that will make it work
I have tried his example, I can build the dll and all. But I cannot register it
not with regsvr32 (dllregisterserver is missing error), not with regasm.exe (no valid assembly error) and not from within navision (could not register OLE).
Any ideas what I need to do?
I still get an error when i use regasm.exe. It tells me that it could not read the file because its not a valid assembly.
Do any of you have a small C# demo project they could share? Just a hello world function that can be called from navsion so that I can check it up against my code? I probably have a small detail wrong.
What I have done so fare: I have set the properties in the assembly to show com and the interop property in the project is also set to true.
When I woke up this morning I had the idea that it might be the regasm.exe that I was using that gave me the problem. So I searched my hard disk for the newest version, and you know what I found a newer one! And now I can create the assembly. As I had to go to work I have not tested the DLL yet but I am pretty sure everything will work out fine now!
Funny how one can focus so much on finding an error in the code and then totally overlook the real simple solution J
Thx for all the excellent input to my forum thread and sorry for all my stupid noob questions!
Ill post a entry when I have everything working.
RIS Plus, LLC
Check it here:
http://demiliani.com/blog/archive/2005/09/19/2965.aspx
1) run Visual Studio (I am using 2003 .Net)
2) File - new - project
3) Visual C# - Windows Control Library (or Class Library), enter the name
4) Define what you need to do (all methods you want to public must be defined as public...)
5) use before your class definition
(using System.Runtime.InteropServices;)
6) Open properties for your project, Configuration properties - Register For COM interop = true
7) Build the project
8) use it in Navision...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
But is there a way to execute the "Windows Control Library" itself, so it will be shown in Navision. Or is that impossible since there`s nothing to add it on to?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Open the globals or the locals and go to the variables tab. Enter a variable name, set the type to automation and click the look up button. From there on out it's basically a trial and error process.
RIS Plus, LLC
So, then there`s no point in using Windows Control Library, you can just use Control Library, since "Windows Control Library" can`t be added or shown anyhow in Navision.
I tried this in Visual Basic with info from demy75
my vb class:
So far it works, what puzzles me is that in the symbol menu in Navision I see some Functions and Properties which I did not define myself (Equals, GetHashCode,GetType,ToString).
Thank you in advance
Thomas
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
This example will expose just one property: HelloWorld()
My blog
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
My thoughts about this: Navision is not capable of using late binding. For that reason you have to know the DispId at designtime. Specifying the DispId in your interface makes the DispId fixed, so Navision is able to store the correct DispId during compilation and use it runtime.
My blog
I've adapted the c# code (from "kaufmann") to vb.net, looks like this:
The default com methods are not shown any more in Navision, but still INavControl and FirstNaviClass are both visible. Is there a possibility to avoid that?
Regards
Thomas
To have the Interface hidden for Navision you have to specify that the Interface is type IUnknown.
By using
However, this will hide the interface information of the methods and properties. If you try this you will see that Navision is not able to determine the return type of the methods and instead is using something like
The other option is to specify your Class as DualInterface. Because every .Net class derives the base interface from the _Object interface, you will see that the Equals, ToString and GetHash methods are specified, along with your interface methods.
My blog
Regards
Thomas
I am using VS 2005.
Example of my code:
But still I am not able to see the properties (I see only the class in Navision, not the interface). I am using StrongName for the class...
I have "Make assembly COM-visible = true" in Project property, "Register for COM interop = true".
Have someone tip where can be the problem?
The class is wrapper for one Automation, which I am opening in new window (it is why the class is inherited from Form class) and on this form I placed visual component "Component".
When I use ClassInterfaceType.AutoDual, I can use the class without problems (but I see all the functions and properties from _Object)...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
to your interface.
My blog
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
My blog
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.