Navision - COM - Web Service

kdw001kdw001 Member Posts: 7
Hello everybody,


I have created a proof of concept where a NAV (version 4.0) CodeUnit calls a COM enabled .NET DLL (written in C#).
The DLL in turns uses a web services to retrieve and update data from an external (non-NAV) application in an external database.
Both concepts individually work fine.
- NAV activating a COM enabled DLL does not cause any difficulties.
- The C# (after converting it to an application) also works fine.

When I merge both features, things go bad...
It seems that I loose web service functionality when I activate the DLL for COM interop.

I receive the following message in NAV:
Could not find default endpoint element that references contract '' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
It seems some kind of configuration is missing for the webservice in the COM-enabled DLL. Does anyone have any experience with this?

When I register the COM DLL, I also receive a warning:
Type library exporter warning processing ''.
Warning: Type library exporter encountered a type that derives from a generic class and is not marked as ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.

Any help would be appreciated.

Regards,
Kurt

Comments

  • kdw001kdw001 Member Posts: 7
    Hello,

    I got a little closer to the solution. The problem is caused by the app.config file.
    Since a COM enabled DLL is not executable, the CLR cannot find the app.config file...

    Regards,
    Kurt
  • kdw001kdw001 Member Posts: 7
    Hi there,

    I found the solution. \:D/
    As mentionned earlier, the problem is caused by the configuration file (app.config).
    Instead of using the default constructor for your web service client like below:
    WebService.TestServiceClient service = new WebserviceFormTest.WebService.TestServiceClient()
    
    you should use the following code:
    EndpointAddress address = new EndpointAddress("http://[servername]/[path_to_wsdl]");
    WebService.TestServiceClient service = new WebserviceFormTest.WebService.TestServiceClient(new BasicHttpBinding(), address);
    

    Hopefully, this short topic ends the ](*,)

    Regards,
    Kurt
  • tlarsontlarson Member Posts: 27
    The other option is to use the app.config file with Navigator. If your application is called myapp.exe, then the config file that goes with it will probably be called myapp.exe.config, and should be in the same directory as myapp.exe. Take that config file, move it to the folder where you have your Navigator exe, such as finsql.exe, and change the name of the config file to finsql.exe.config. Then start finsql.exe and it should pick up on the configuration file and the error should go away.

    However, the solution you outline should work just as well, and not require as much mucking around on the client filesystem.

    Tim Larson
  • SpycoclownSpycoclown Member Posts: 13
    tlarson wrote:
    The other option is to use the app.config file with Navigator. If your application is called myapp.exe, then the config file that goes with it will probably be called myapp.exe.config, and should be in the same directory as myapp.exe. Take that config file, move it to the folder where you have your Navigator exe, such as finsql.exe, and change the name of the config file to finsql.exe.config. Then start finsql.exe and it should pick up on the configuration file and the error should go away.

    However, the solution you outline should work just as well, and not require as much mucking around on the client filesystem.

    Tim Larson

    I Know the post is pretty old but i have a little problem.

    What do i do if i have more then one app.config file?

    I cant use the EndpointAddress because i have a https link and not like expected a http.

    So does anybody have an idea how i can solve that problem? i cant use the finsql.exe.config because i use more then one config file and EndpointAddress don't work because i have https.

    hope somebody could help me.
Sign In or Register to comment.