PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > ASP.NET教程 > 正文

    The service cannot be activated because it does not support ASP.NET compatibility

    作者:admin来源:网络浏览:时间:2020-09-30 00:07:50我要评论
    导读:刚刚在ASP.NET创建一个Service,在运行时,它即显示异常:The service cannot be activated because it does not support ASP.NET...
    刚刚在ASP.NET创建一个Service,在运行时,它即显示异常:

    The service cannot be activated because it does not support ASP.NET compatibility

     

    The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.

    解决方法,你需要为你的Service添加一个属性:
    The service cannot be activated because it does not support ASP.NET compatibility


    第#11行代码:

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]


    上面的解决方法,它只是为单独某一个Service。如果你有多个Service时,那需要在每一个Service均需要添加上面的属性。
    有一个更好的方法,就是修改web.config:
    The service cannot be activated because it does not support ASP.NET compatibility

     
    http://www.cnblogs.com/insus/p/4919539.html
    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-11-2999-1.html
    相关热词搜索: