none
WCF: exePath must be specified when not running inside a stand alone exe RRS feed

  • Question

  • Dear all i have problem with WCF Service.

    Administration WPF project (exe) is trying to read config file one of WCF service (Read AppSettings).
    Application works properly, successfully read and write App.config file while in debug mode (as VS host Services automatically (Service host environment)), but when i deploy services on IIS, I face bellow exception.

    Here is detail description of Exception

    exePath must be specified when not running inside a stand alone exe.
    Type: System.ArgumentException:
    Source:
    System.Configuration
    Data:
    Stack Trace:    at System.Configuration.ConfigurationManager.OpenExeConfigurationImpl(ConfigurationFileMap fileMap, Boolean isMachine, ConfigurationUserLevel userLevel, String exePath, Boolean preLoad)
       at Business.XXXService.AdminService.ReadEmailConfiguration(GenericRequest`1 request) in E:\Source\MB Services\Source Code\Source Code\Business\NFS.Business.COSService\ServicesImpl\AdminService.cs:line 388

    As I understand, In development mode, there is aap.config file for services (WCF Service library project), but when going to deploy on IIS, configuration read from Web.config
    So I implemented both cases.
    Here is implementation of reading config file, But still face issue on deployed Service.

    Configuration configuration = null;
    
                    if (HttpContext.Current != null)
                        configuration = WebConfigurationManager.OpenWebConfiguration("~");
                    else
                        configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    
                    if (configuration == null)
                    {
                        response.Status.Code = ReturnCode.DataNotFound.GetStringValue();
                        response.Status.Message = "Unable to read configuration";
                        return response;
    
                    }

    I think there is no need to investigate in app/web.config therefore I am not attaching config File

    Thanks in Advance

    Kamran Asim


    • Edited by Kamran Asim Wednesday, June 5, 2013 5:07 AM detial changed
    Wednesday, June 5, 2013 5:05 AM

Answers

  • Dear All,

    Issue Solved.

    You need to enable asp compatibility bellow steps can solve such issue.

    set AspnetCompatibilityEnabled true in web.config (If you are using WCF service library then add AspnetCompatibilityEnabled in ServiceModel Node in aap.config)


    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    .
    .
    .
    </system.serviceModel

    Second you need to compatible service with asp.net by adding bellow attribute

     [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class AdminService : IAdminService
        {
    .
    .

    • Marked as answer by Kamran Asim Wednesday, June 5, 2013 9:21 AM
    Wednesday, June 5, 2013 9:21 AM

All replies

  • Dear All,

    Issue Solved.

    You need to enable asp compatibility bellow steps can solve such issue.

    set AspnetCompatibilityEnabled true in web.config (If you are using WCF service library then add AspnetCompatibilityEnabled in ServiceModel Node in aap.config)


    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    .
    .
    .
    </system.serviceModel

    Second you need to compatible service with asp.net by adding bellow attribute

     [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
        public class AdminService : IAdminService
        {
    .
    .

    • Marked as answer by Kamran Asim Wednesday, June 5, 2013 9:21 AM
    Wednesday, June 5, 2013 9:21 AM
  • Hi,

    Glad to hear that the issue was resolved, thanks for sharing your solution here.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 6, 2013 1:59 AM
    Moderator
  • Sir,

    Appreciate for your sharing. That helps a lot and save my time.

    Regards.

    Monday, July 29, 2013 8:33 AM