C# COM dll - Could not create an instance of the OLE control or Automation server

MarcusRB
Member Posts: 40
Hello,
I'm developing a report for Navision 2009 SP1, where the need for extra functionality unavailable in NAV has arisen.
I have created a COM dll in C#, installed it and created an automation variable in NAV. When I try to CREATE it, I get the following error:
"Could not create an instance of the OLE control or Automation server identified by..... Check that the OLE control or Automation server is correctly installed and registered."
The DLL should be correct, this is the code (just sample code to get a working connection between NAV and DLL):
The DLL is registered as a COM dll through InstallShield.
I hope you have enough information, or have been in the same situation and can help out.
Best regards
Marcus
I'm developing a report for Navision 2009 SP1, where the need for extra functionality unavailable in NAV has arisen.
I have created a COM dll in C#, installed it and created an automation variable in NAV. When I try to CREATE it, I get the following error:
"Could not create an instance of the OLE control or Automation server identified by..... Check that the OLE control or Automation server is correctly installed and registered."
The DLL should be correct, this is the code (just sample code to get a working connection between NAV and DLL):
[ComVisible(true), Guid("080a97fb-321c-4a2f-b948-dd52ce263415"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IPrinterTest { [DispId(1)] bool Print(string test, string bytesInStringRepresentation); } [ClassInterface(ClassInterfaceType.None), ComVisible(true), Guid("8d7b85a9-1a20-4ea0-a7d4-decf26632eee"), ProgId("Printer.PrinterTest")] public class PrinterTest : IPrinterTest { public PrinterTest() { } public bool Print(string test, string bytesInStringRepresentation) { return true; } }
The DLL is registered as a COM dll through InstallShield.
I hope you have enough information, or have been in the same situation and can help out.
Best regards
Marcus
0
Answers
-
Does the dll come with a tlb.0
-
Duikmeester wrote: »Does the dll come with a tlb.
I used regasm to generate a .tlb file and added it to the InstallShield setup.0 -
Did you use target framework 3.5? I have had also trouble before when targeting higher frameworks with 2009R2.0
-
Duikmeester wrote: »Did you use target framework 3.5? I have had also trouble before when targeting higher frameworks with 2009R2.
No, I used 4.0, I'll give 3.5 a whirl and report back
EDIT: My bad, I was repairing a newer version of VS and didn't have access to the project, I am using 3.50 -
Duikmeester wrote: »Did you use target framework 3.5? I have had also trouble before when targeting higher frameworks with 2009R2.
My bad, I was repairing a newer version of VS and didn't have access to the project, I am using 3.50 -
When run as Administrator and you build it in Visual Studio with [assembly: ComVisible(true)] and Register for COM interop in the Properties. Then it should pick up the DLL in the Build folder instead of the installer. I suspect the installer not doing the correct registrations.0
-
Duikmeester wrote: »When run as Administrator and you build it in Visual Studio with [assembly: ComVisible(true)] and Register for COM interop in the Properties. Then it should pick up the DLL in the Build folder instead of the installer. I suspect the installer not doing the correct registrations.
I think you're right. I don't know how I should deploy the DLL and register it for COM interop manually on a non-developer PC (client pc) with .NET Framework Client Profile (don't know if that makes a difference either, shouldn't think so).0 -
Anyone else got an idea?0
-
For .NET Assemblies with COM Interface I use Visual Studio 2010 Setup Project and the deployment / installation works fine for me.
I have several .NET Assemblies which I created and I use them for oldschool nav clients (NAV5.0) using COM interfaces and the setup is always done with VS2010 setups (Windows Installer .msi)
But:
Your problem could be also a dependency loading issue. - Have a look at this:
http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net0 -
For .NET Assemblies with COM Interface I use Visual Studio 2010 Setup Project and the deployment / installation works fine for me.
I have several .NET Assemblies which I created and I use them for oldschool nav clients (NAV5.0) using COM interfaces and the setup is always done with VS2010 setups (Windows Installer .msi)
But:
Your problem could be also a dependency loading issue. - Have a look at this:
http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net
Thank you thank you thank you!
I had no idea that Visual Studio had an installer toolset... By fiddling around with the VS installer project, I was able to correctly register the DLL for COM interop.
The key points to successfully registering a .NET DLL for COM interop are as follows:- Make sure that the assembly is strong signed, otherwise it won't get registered for COM interop.
- The interface/class has to conform to these requirements:
- The names must match, e.g. IPrintTest and PrintTest.
- They must be public and "ComVisible".
- You have to generate a TLB file for the DLL and add it to the installer filesystem.
I would provide you (you = everybody else with this issue, that might see this in the future) the project, but I can't since this is work related. I will however write a blog post about this when I get home and provide an example project there.0
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