Accessing COM Component from Classic ASP which con

2020-08-02 02:19发布

问题:

I created a COM interop component using ClassLibrary which consumes WCF. Now when I call COM component's Method (which uses WCF) from my Classic ASP page, I'm getting the following error.

Error Type: System.ServiceModel (0x80131509) Could not find default endpoint element that references contract 'DLSWS.IDLSWS' 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.

What I understand from the above error is : asp page is not able read the WCF configuration from the app.config file within the COM Component. How can i resolve this issue?

回答1:

You could either set your endpoint programatically when creating the client channel inside your COM object or use an app.config.

To set an app.config for COM+ application:

If you are using Windows 2000, and your COM+ app is a server one, your app.config should be called dllhost.exe.config and must be in the same directory as dllhost.exe (which is %SystemRoot%\System32).

If you are using Windows 2003, you can go to the Activation tab of the COM+app properties and set the Application Root Directory property to point to a location of your preference, and, in that directory, you must place a file called application.config (with your config settings) and another file caller application.manifest with the content shown bellow:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
</assembly>


回答2:

Does the COM component have an App.config file? If not, it's likely that the COM cannot access the configuration in web.config.

Either create an App.config file for the component or pass in the Endpoint instance from the web application.