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):
[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
Answers
I used regasm to generate a .tlb file and added it to the InstallShield setup.
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.5
My bad, I was repairing a newer version of VS and didn't have access to the project, I am using 3.5
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).
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:
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.