1

我使用 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

有什么建议么?

4

1 回答 1

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>
于 2014-05-05T19:57:45.450 回答