小编use*_*493的帖子

找不到引用合同的默认端点元素

我知道这已经被打死了,但是我无法让它按原样运作.我有几个合同的WCF服务.直接调用它们时它们都可以正常工作,例如 http://merlin.com/CompanyServices/CompanyWcfService.svc/Get_Document_Dates_Received/223278 我在InfoPath Forms和Nintex Workflows上成功使用了这个WCF服务.现在我创建一个简单的ASP.Net应用程序,例如在http://www.webcodeexpert.com/2013/04/how-to-create-and-consume-wcf-services.html中完成的.我能够添加文章中描述的服务引用.我在表单中添加了一个按钮,并在Button1_Click事件中添加了以下代码:

protected void Button1_Click(object sender, EventArgs e)
{
    ServiceReference1.CompanyWcfServiceClient x = new ServiceReference1.CompanyWcfServiceClient();
    var result = x.Get_Document_Dates_Received("223278");
}
Run Code Online (Sandbox Code Playgroud)

当我点击按钮时出现错误:

"无法在ServiceModel客户端配置部分找到引用合同'ServiceReference1.ICompanyWcfService'的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素".

所以我尝试将以下内容添加到web.config中:(直接从CompanyWcfService的web.config文件中复制.

<system.serviceModel>
<services>
  <service name="CompanyWcfServices.CompanyWcfService" behaviorConfiguration="ServiceBehavior">
    <endpoint address="" binding="webHttpBinding" contract="CompanyWcfServices.ICompanyWcfService" behaviorConfiguration="webHttpEndpointBehavior" >
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">                                                                
    </endpoint>
  </service>
</services>
<bindings>
  <webHttpBinding>
    <binding>
      <security mode="None">
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name ="webHttpEndpointBehavior">
      <webHttp helpEnabled ="true" faultExceptionEnabled="true" automaticFormatSelectionEnabled="true"/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug …
Run Code Online (Sandbox Code Playgroud)

wcf

12
推荐指数
4
解决办法
7万
查看次数

动态注册通用类型

我想使用Unity注册一个通用的Repository类.

这是我的通用类:

public class Repository<TModel> 
    : IRepository<TModel> where TModel : class, IModel
Run Code Online (Sandbox Code Playgroud)

TModel是与Entity一起使用的POCO对象.

如果我这样注册就行了.

IOC_Container.RegisterType(typeof(IRepository<Employee>), typeof(Repository<Employee>));
Run Code Online (Sandbox Code Playgroud)

这需要我注册每个TModel,这变得很麻烦.

我有一个使用反射动态注册我的服务类的引导程序,我想对存储库执行相同的操作.

这是服务的引导程序代码:

var currentAssembly = Assembly.LoadFrom(assembly);
var assemblyTypes = currentAssembly.GetTypes();

foreach (var assemblyType in assemblyTypes)
{
    if (assemblyType.IsInterface)
    {
        continue;
    }

    if (assemblyType.FullName.EndsWith("Service"))
    {
        foreach (var requiredInterface in assemblyType.GetInterfaces())
        {
            if (requiredInterface.FullName.EndsWith("Service"))
            {
                var typeFrom = assemblyType.GetInterface(requiredInterface.Name);
                var typeTo = assemblyType;
                IOC_Container.RegisterType(typeFrom, typeTo);
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

}

有什么建议?

c# unity-container

2
推荐指数
1
解决办法
1253
查看次数

Serilog 最低级别.覆盖

我的问题是,当涉及到源代码时,我需要对 Serilog MinimumLevel.Override 进行多细化?

例如,我希望将来自 Microsoft 的所有消息都记录在警告级别。

来源“Microsoft”是否足够?

.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
Run Code Online (Sandbox Code Playgroud)

或者我需要做这样的事情:

.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
....
Run Code Online (Sandbox Code Playgroud)

serilog

1
推荐指数
1
解决办法
4307
查看次数

从视图内的存储过程中选择

有人可以告诉我为什么这不起作用?

我有一个返回表的存储过程:调用它就像这样工作正常:

EXECUTE dbo.sp_Get_Total_Parcels_Paid_Data
Run Code Online (Sandbox Code Playgroud)

但是,我需要在视图中使用它,并且无法使其工作.

Select * from dbo.sp_Get_Total_Parcels_Paid_Data()
Run Code Online (Sandbox Code Playgroud)

错误:

无效的对象名称'dbo.sp_Get_Total_Parcels_Paid_Data()

SP代码:

create PROCEDURE [dbo].[sp_Get_Total_Parcels_Paid_Data]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

declare @Sql1 nvarchar(max)
,@Sql2 nvarchar(max)
,@Sql3 nvarchar(max)

declare @TallyResults table
(EFOLDERID nvarchar(31) null    
,inv_bank_cd int null
,inv_cd int null
,inv_group_cd int null
,intLoanNumber int null
,other_text nvarchar(250) null
,tallyCount int
,eidMgrId nvarchar(31))


select @Sql1 = 'Select ' + tallydefinition from jobfunctions where jobfuncid = …
Run Code Online (Sandbox Code Playgroud)

sql-server

-1
推荐指数
1
解决办法
4万
查看次数

标签 统计

c# ×1

serilog ×1

sql-server ×1

unity-container ×1

wcf ×1