First WCF遇到的问题

1. ========================================================================
<%@ServiceHost language=C# Debug="true" Service="Microsoft.ServiceModel.Samples.CalculatorService" %> 显示了明文,没有进行解析。
-------------------------------------------------------------------solution----------------------------------------------------------------------------------------------
需要将.svc扩展名和aspnet_isapi.dll关联

1.        打开IIS管理器.

2.        右单击 Web Sites 并且选择属性 Properties.

3.        On the Home Directory tab, click 配置Configuration.

4.        In the list of application mappings, verify that the .svc file is mapped to the aspnet_isapi.dll. If the file has not been mapped:

a.                  单击增加按钮.

b.                  在 Add/Edit Application Extension Mapping 对话框中, 单击浏览按钮

c.                  找到aspnet_isapi.dll并单击Open.

d.                  制定 .svc 扩展名

e.                  确保Check that file exists 选项没有被选中.

f.                    单击确定, 然后再单击确定回到站点属性窗口.

5.        单击确定关闭站点属性窗口。

3然后就可以在IE窗口中测试时候正常运行了。(http://localhost/servicemodelsamples/service.svc).

refer to     http://msdn2.microsoft.com/zh-cn/library/ms752252.aspx


2. ============================================================================
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.

The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:


[HostingEnvironmentException: Failed to access IIS metabase.]
   System.Web.Configuration.MetabaseServerConfig.MapPathCaching(String siteID, VirtualPath path) +3609834
   System.Web.Configuration.MetabaseServerConfig.System.Web.Configuration.IConfigMapPath2.MapPath(String siteID, VirtualPath vpath) +9
   System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +169
   System.Web.CachedPathData.GetConfigPathData(String configPath) +382
   System.Web.CachedPathData.GetConfigPathData(String configPath) +243
   System.Web.CachedPathData.GetApplicationPathData() +68
   System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) +3503459
   System.Web.Configuration.RuntimeConfig.GetLKGRuntimeConfig(VirtualPath path) +189
---------------------------------------------------solution----------------------------------------------------------------------------------------------

RESOLUTION
Follow the steps given below to fix this error
 
(1) Go to Start | Control Panel | Add and Remove Programs
 
(2) Click on the entry titled Microsoft .NET Framework 2.0 and select Change/Remove. The Microsoft .NET Framework 2.0 Setup dialog box opens up.
 
(3) Select the option titled Repair and the setup automatically performs the required repair work.
 
(4) You will be prompted to reboot the system after the completion of the process.
 
(5) Run the affected ASP.NET 2.0 application once again and the application should work fine without any problems.

3=============================================================================
 当发布wcf service 出现类似如下错误时,表示你的配置文件有问题:

This is a Windows© Communication Foundation service.

Metadata publishing for this service is currently disabled.

If you have access to the service, you can enable metadata publishing by completing the following steps to modify your web or application configuration file…

上面的错误指出:缺少Metadata 节点,因此我们可以在我们的wcf配置文件中添加Metadata 节点,并设置httpGetEnabled 属性为ture.

 

4=============================================================================

在配置address的时候,localhost似乎不行,需要改成机器名。因为它需要 IIS Address。

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.serviceModel>
    <services>
      <!-- Before deployment, you should remove the returnFaults behavior configuration to avoid disclosing information in exception messages -->
      <service name="MyService" behaviorConfiguration="returnFaults">
        <endpoint contract="IMyService" binding="wsHttpBinding" address="http://tc/Demo/Service.svc"/>   // here tc is the machine name.
      </service>
    </services>


5============================================================================================
Could not find default endpoint element that references contract 'MyServiceOf_Person' 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.

new MyServiceOf_PersonClient(); 的时候出现上面的错误是因为没有找到配置文件。客户端的配置有两种,
1) 在程序里设置:

            WSHttpBinding binding = new WSHttpBinding();
            binding.TransactionFlow = true;
            ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
            behavior.HttpGetEnabled = true;

new MyServiceOf_PersonClient(binding, new EndpointAddress(address));

2) 写配置文件 app.config并且放在dll的同一个目录。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值