为什么我的自定义WCF行为扩展元素类型被发现? [英] Why isn't my custom WCF behavior extension element type being found?

查看:409
本文介绍了为什么我的自定义WCF行为扩展元素类型被发现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个项目的解决方案。其中一个项目是一个ASP.NET Web应用程序项目,一个是类库。 Web应用程序有一个项目引用类库。这些都不是强命名的。

I have a solution that contains two projects. One project is an ASP.NET Web Application Project, and one is a class library. The web application has a project reference to the class library. Neither of these is strongly-named.

在类库,我会打电话给框架,我有一个终结点行为(一IEndpointBehavior实现)和一个配置元素(从BehaviorExtensionsElement派生的类)。配置元素,所以我可以通过配置连接端点行为的服务。

In the class library, which I'll call "Framework," I have an endpoint behavior (an IEndpointBehavior implementation) and a configuration element (a class derived from BehaviorExtensionsElement). The configuration element is so I can attach the endpoint behavior to a service via configuration.

在Web应用程序中,我有一个支持AJAX的WCF服务。在web.config中,我必须配置为使用我的自定义行为AJAX服务。配置的system.serviceModel部分是pretty的标准是这样的:

In the web application, I have an AJAX-enabled WCF service. In web.config, I have the AJAX service configured to use my custom behavior. The system.serviceModel section of the configuration is pretty standard and looks like this:

<system.serviceModel>
 <behaviors>
  <endpointBehaviors>
   <behavior name="MyEndpointBehavior">
    <enableWebScript />
    <customEndpointBehavior />
   </behavior>
  </endpointBehaviors>
 </behaviors>
 <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
 <services>
 <service name="WebSite.AjaxService">
  <endpoint
           address=""
           behaviorConfiguration="MyEndpointBehavior"
           binding="webHttpBinding"
           contract="WebSite.AjaxService" />
  </service>
 </services>
 <extensions>
  <behaviorExtensions>
   <add
       name="customEndpointBehavior"
       type="Framework.MyBehaviorExtensionsElement, Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </behaviorExtensions>
 </extensions>
</system.serviceModel>

在运行时,这个完美的作品。在AJAX的WCF服务正确使用我的自定义配置的端点行为。

At runtime, this works perfectly. The AJAX enabled WCF service correctly uses my custom configured endpoint behavior.

现在的问题是,当我尝试添加新的AJAX WCF服务。如果我添加 - >新项...,然后选择支持AJAX的WCF服务,我可以看它添加.svc文件和codebehind,但是当它到达更新web.config文件,我得到这个错误:

The problem is when I try to add a new AJAX WCF service. If I do Add -> New Item... and select "AJAX-enabled WCF Service," I can watch it add the .svc file and codebehind, but when it gets to updating the web.config file, I get this error:

配置文件是不是WCF服务库有效的配置文件。

The configuration file is not a valid configuration file for WCF Service Library.

类型Framework.MyBehaviorExtensionsElement,框架,版本= 1.0.0.0,文化=中性公钥=空'注册为扩展名customEndpointBehavior无法加载的。

The type 'Framework.MyBehaviorExtensionsElement, Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'customEndpointBehavior' could not be loaded.

显然,配置是​​完全有效的,因为它完美的运行。如果我从我的行为配置中删除的元素暂时然后添加支持AJAX的WCF服务,一切都顺利。

Obviously the configuration is entirely valid since it works perfectly at runtime. If I remove the element from my behavior configuration temporarily and then add the AJAX-enabled WCF Service, everything goes without a hitch.

不幸的是,在一个较大的项目,我们将有多个服务,各种配置,删除所有临时的自定义行为的将是容易出错。虽然我知道我可以去没有使用向导,并尽一切手动,不是每个人都可以,它会是不错的能够只使用该产品,因为它是为了使用 - 向导和所有的

Unfortunately, in a larger project where we will have multiple services with various configurations, removing all of the custom behaviors temporarily is going to be error prone. While I realize I could go without using the wizard and do everything manually, not everyone can, and it'd be nice to be able to just use the product as it was meant to be used - wizards and all.

为什么我的自定义WCF行为扩展元素类型被发现?

更新/澄清:

  • 在它的工作在运行时,只是没有设计时间。
  • 在该框架组件是Web项目的bin文件夹,当我尝试添加该服务。
  • 虽然我可以(不配置)手动添加服务,我需要出的现成的项目模板的工作 - 这就是问题的全部目标迈进。
  • 在此问题正在出现在Visual Studio 2008中的在VS 2010中这似乎得到解决。
  • It does work at runtime, just not design time.
  • The Framework assembly is in the web project's bin folder when I attempt to add the service.
  • While I could add services manually ("without configuration"), I need the out-of-the-box item template to work - that's the whole goal of the question.
  • This issue is being seen in Visual Studio 2008. In VS 2010 this appears to be resolved.

我在Microsoft Connect上提起这个问题,事实证明,你要么把你的自定义的配置元素在GAC中或将其放在IDE文件夹。他们不会被修复它,至少现在是这样。我已为他们提供的答案这个问题的解决办法。

I filed this issue on Microsoft Connect and it turns out you either have to put your custom configuration element in the GAC or put it in the IDE folder. They won't be fixing it, at least for now. I've posted the workaround they provided as the "answer" to this question.

推荐答案

解决方法微软发布在 我申请了这个连接问题,这是一个已知的问题而且不会有它在当前版本的任何解决方案,至少有:

Per the workaround that Microsoft posted on the Connect issue I filed for this, it's a known issue and there won't be any solution for it, at least in the current release:

的原因未能添加新的   服务项目:增加一个新项目时   和更新配置文件,   系统会试图加载   配置文件,所以它会尝试   搜索和加载的程序集   cusom扩展在此配置文件。   只有在案件的组装   GACed或位于相同的路径   作为VS exe文件(程序Files \ Microsoft   的Visual Studio 9.0 \ Common7 \ IDE)中,   系统能够找到它。否则,该   错误对话框会弹出和添加   新项目将失败。

The reason for failing to add a new service item: When adding a new item and updating the configuration file, the system will try to load configuration file, so it will try to search and load the assembly of the cusom extension in this config file. Only in the cases that the assembly is GACed or is located in the same path as vs exe (Program Files\Microsoft Visual Studio 9.0\Common7\IDE), the system can find it. Otherwise, the error dialog will pop up and "add a new item" will fail.

我明白你的痛点。   不幸的是,我们不能把这个   改变当前版本。我们会   调查它在以后的版本和   尽量提供更好的解决方案   那么,如提供一个浏览对话框   使客户能够指定   路径,或者更好的错误消息   表明围绕解决方案的一些工作,   等等...

I understand your pain points. Unfortunately we cannot take this change in current release. We will investigate it in later releases and try to provide a better solution then,such as providing a browse dialog to enable customers to specify the path, or better error message to indicate some work around solution, etc...

你能在目前各地尝试的工作   阶段:GAC您的自定义扩展   装配或将其复制到程序   文件\微软的Visual Studio   9.0 \ Common7 \ IDE?

Can you try the work around in current stage: GAC your custom extension assembly or copy it to "Program Files\Microsoft Visual Studio 9.0\Common7\IDE"?

我们将提供自述帮助   谁可能会遇到的其他客户   同样的问题。

We will provide the readme to help other customers who may run into the same issue.

不幸的是,它似乎我的运气就这一个。

Unfortunately, it appears I'm out of luck on this one.

这篇关于为什么我的自定义WCF行为扩展元素类型被发现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆