【问题标题】:Unity Interception MethodSignatureMatchingRule could not be resolvedUnity拦截方法SignatureMatchingRule无法解析
【发布时间】:2013-11-22 09:01:40
【问题描述】:

我正在使用 Unity (3.0) 拦截向我的应用程序添加一些横切关注点。不知何故,我无法在我的配置中使用 MethodSignatureMatchingRule 收到此错误消息:

{"The type name or alias MethodSignatureMatchingRule could not be resolved. Please check your configuration file and verify this type name."}

我的配置:

<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
  <sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
  <alias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
  <containers>
    <container name="MyContainer">
      <extension type="Interception"/>
      <interception>
        <policy name="EhabAspect">
          <matchingRule name="MethodSignatureMatchingRule" type="MethodSignatureMatchingRule">
            <constructor>
              <param name="methodName" value="Receive" type="string"/>
            </constructor>
          </matchingRule>
          <callHandler ... (omitted)
        </policy>
      </interception>
      <register type="IMyClass" mapTo="MyClass">
        <lifetime type="singleton" />
        <interceptor type="InterfaceInterceptor"/>
        <policyInjection/>
      </register>
    </container>
  </containers>
</unity>

NamespaceMatchingRule 相同的配置工作正常。

我的程序集包含对

的引用
  • Microsoft.Practices.EnterpriseLibrary.Common
  • Microsoft.Practices.Unity
  • Microsoft.Practices.Unity.Configuration

有什么建议吗?

【问题讨论】:

  • 您是否尝试指定 MethodSignatureMatchingRule 类型的完整限定名?
  • 还没有。但是 MethodSignatureMatchingRule 的别名应该已经由 Interception 扩展注册。如果可行,我会尝试并更新我的问题

标签: unity-container enterprise-library unity-interception cross-cutting-concerns


【解决方案1】:

我在这里遇到了同样的问题。我使用类的完整限定名解决了。

<matchingRule name="AuthorizationMethod" type="Microsoft.Practices.Unity.InterceptionExtension.MethodSignatureMatchingRule, Microsoft.Practices.Unity.Interception">
  <constructor>
    <param name="methodName" value="Authenticate" type="string"/>
    <param name="parameterTypeNames" dependencyName="EmptyArray"/>
  </constructor>
</matchingRule>

【讨论】:

    猜你喜欢
    • 2016-04-13
    • 1970-01-01
    • 2012-02-10
    • 2013-05-23
    • 2011-04-16
    • 2012-09-24
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    相关资源
    最近更新 更多