2011-01-13 13 views
7

मैं सिल्वरलाइट क्लाइंट एप्लिकेशन में डब्ल्यूसीएफ सेवा से नियमित अपवादों को पकड़ने की कोशिश कर रहा हूं। इसके लिए मैंने in this MSDN article दिए गए अनुसार मेरी डब्ल्यूसीएफ सेवा में संबंधित परिवर्तन शामिल किए हैं।तत्व 'व्यवहार' में अमान्य बाल तत्व 'myFaultExtension' है wcf app.config

लेकिन जब मैं व्यवहार विस्तार को कॉन्फ़िगर करता हूं और एंडपॉइंट व्यवहार में इसका उपयोग करता हूं, तो ऊपर वर्णित त्रुटि आ रही है, और सेवा इस त्रुटि के कारण चलने में सक्षम नहीं है।

मैं यहां अपनी कॉन्फ़िगरेशन डाल रहा हूं। कृपया सुझाव दें कि मैं इसे कैसे हल कर सकता हूं?

<extensions> 
     <!--Add a behavior extension within the service model--> 
     <!-- Here SilverlightFaultBehavior is a class in AppServiceLib namespace --> 
     <behaviorExtensions> 
     <add name="myFaultExtension" 
      type="AppServiceLib.SilverlightFaultBehavior,AppServiceLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
     </behaviorExtensions> 
    </extensions> 
    <endpointBehaviors> 
     <behavior name="myFaultBehavior"> 
      <**myFaultExtension**/> 
     </behavior> 
    </endpointBehaviors> 
+0

http://connect.microsoft.com/VisualStudio/feedback/details/619106/wcf-fails-to-find-custom-behaviorextensionelement-if-type-attribute-doesnt-match-exactly – nologo

+0

संभव डुप्लिकेट [सुनवाई "तत्व 'व्यवहार' में अमान्य बाल तत्व है" को अनदेखा किया जाना चाहिए, लेकिन इसके कारण सेवा संदर्भ को अपडेट करने से रोका गया है] (http://stackoverflow.com/questions/9482091/hearing-element-behavior-has-invalid- बच्चे-तत्व-होना-अनदेखा-लेकिन-पीआर) – McGarnagle

उत्तर

0

आप जब WCF कॉन्फ़िग फ़ाइल बनाने, के बाद से वी.एस. संपादक है कि विस्तार के बारे में पता नहीं है दृश्य स्टूडियो में इस त्रुटि हो रही हो सकता है।

लेकिन क्या यह रनटाइम पर भी होता है ??

आप इस व्यवहार का उपयोग कैसे और कहाँ कर रहे हैं? सर्वर की तरफ? ग्राहक पक्ष पर? दोनों?

0

मैं इस मुद्दे में भाग गया। मेरे लिए समाधान वास्तव में उपरोक्त डुप्लिकेट पोस्टिंग Hearing "element 'behavior' has invalid child element" should be ignored, but prevented from updating service reference because of it में प्रदान किया गया था। 'प्रकार' फ़ील्ड को चालू करना बहुत संवेदनशील है। सटीक प्रकार की आवश्यकता के लिए का उपयोग दूसरे पोस्ट पर answer के रूप में वर्णित किया गया।

<add name="myFaultExtension" 
     type="AppServiceLib.SilverlightFaultBehavior,AppServiceLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
+0

मेरे लिए काम नहीं किया। –

+0

@ अकिरा: मेरा जवाब जांचें, यह आपकी मदद कर सकता है। –

2

यह समस्याओं जब विधानसभा के संस्करण के दौरान autoincremented है विधानसभा संकलन/निर्माण का कारण बनता है।

.NET 4.0 के बाद से तय किया गया। संस्करण/संस्कृति/PublicKeyToken को छोड़ दिया जा सकता है ताकि कॉन्फ़िगरेशन को अब संस्करण के स्वत: संक्रमित मूल्य की आवश्यकता न हो।

<behaviorExtensions> 
    <add name="serviceKeyBehavior" 
    type="MyNamespace.ServiceKeyBehaviorExtensionElement, MyAssembly"/> 
</behaviorExtensions> 
0

गलतियों को रोकने के लिए संपादक के साथ web.config में अपने डब्ल्यूसीएफ को परिभाषित करने का प्रयास करें। (विशेष रूप से जब आपको पूरे प्रकार के नाम लिखने की आवश्यकता होती है)।

सही web.config पर क्लिक करें, फिर संपादित करें WCF विन्यास:

enter image description here

तो यहां जाएं: उन्नत -> एक्सटेंशन -> व्यवहार तत्व एक्सटेंशन -> नई

enter image description here

फिर नीचे (सामान्य) बाएं छोटे बटन पर क्लिक करें और नया व्यवहार चुनें। यह आपके लिए app.config में पूर्ण प्रकार का नाम लिख देगा।

enter image description here

अब आप सही प्रकार नाम के साथ app.config में <extensions> टैग के तहत अपने नए व्यवहार देख सकते हैं।

1

मुझे यह त्रुटि मेरे कस्टम व्यवहार एक्सटेंशन के साथ मिली थी जिसे मैं एंडपॉइंट व्यवहार के रूप में जोड़ना चाहता था। इसलिए, मैंने अपने web.config फ़ाइल में चेतावनी से छुटकारा पाने के लिए विजुअल स्टूडियो 2017 में उपयोग की गई स्कीमा संपादित की।यह वही चेतावनी है जिसे आपने प्राप्त किया:

तत्व 'व्यवहार' में अमान्य बाल तत्व 'कस्टम सुरक्षा' है। अपेक्षित संभावित तत्वों की सूची: 'क्लाइंटविया, कॉलबैकडिबग, कॉलबैकटाइमआउट, स्पष्ट, क्लाइंट क्रेडेंशियल्स, ट्रांज़ेक्टेड बैचिंग, डेटा कंट्रैक्टसाइरियलाइज़र, डिस्पैचर सिंक्रनाइज़ेशन, हटाएं, सिंक्रोनस रिसीसीव, वेब एचटीपी, सक्षम वेबस्क्रिप्ट, एंडपॉइंट डिस्वरी, साबुनप्रोसेसिंग'।

मेरे web.config है:

<system.serviceModel> 
    <extensions> 
     <behaviorExtensions> 
      <add name="CustomSecurity" 
       type="FullyQualifiedPath.MyCustomBehaviorExtension, MyAssemblyName"/> 
      </behaviorExtensions> 
    </extensions> 
    <endpointBehaviors> 
     <behavior name="CustomServiceBehavior"> 
      <CustomSecurity /> 
     </behavior> 
    </endpointBehaviors> 
    <endpoint address="https://SomeServer/MyService.svc/soap" 
    behaviorConfiguration="CustomServiceBehavior" binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_IProject" contract="ProjectService.IProject" 
    name="BasicHttpBinding_IProject" /> 

CustomSecurity एक्सएमएल नोड हमेशा दृश्य स्टूडियो में इसे नीचे नीले टेढ़ा-मेढ़ा लाइन थी। यह त्रुटि सूची विंडो में चेतावनी के रूप में दिखाई देता है। मैं इससे छुटकारा पाना चाहता था क्योंकि हर बार जब मैंने सेवा संदर्भ को अपडेट करने का प्रयास किया था, तो यह web.config में चेतावनी के कारण विफल हो जाएगा।

तो, इसे ठीक करने के लिए, आपको स्कीमा संपादित करना होगा जो विजुअल स्टूडियो तत्वों को सत्यापित करने के लिए उपयोग करता है। इसलिए, मैंने अपना web.config खोला, फिर मुख्य विजुअल स्टूडियो मेनू बार पर एक्सएमएल चुना। फिर Schemas का चयन करें। आपको स्कीमा की एक लंबी सूची मिल जाएगी। जैसा कि नीचे देखा गया है "DotNetConfig.xsd" खोजें। enter image description here

दिखाए गए पथ पर ब्राउज़ करें और xsd फ़ाइल संपादित करें। के लिए खोजें: <xs:element name="behavior" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior">

फिर एक नया एक्सएस जोड़ें: xs के भीतर तत्व नोड: अपने कस्टम व्यवहार एक्सटेंशन के नाम के साथ पसंद नोड; मेरे मामले में, कस्टम सुरक्षा। फ़ाइल को सहेजें और विजुअल स्टूडियो को स्वचालित रूप से नई स्कीमा के विरुद्ध सत्यापित करना चाहिए और आपको अब अपने web.config में कोई चेतावनी नहीं मिलनी चाहिए।

<xs:element name="behavior" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior"> 
<xs:complexType> 
<xs:annotation> 
    <xs:documentation>The behavior element contains a collection of settings for the behavior of an endpoint.</xs:documentation> 
</xs:annotation> 
<xs:choice minOccurs="0" maxOccurs="unbounded"> 
    <xs:element name="CustomSecurity" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior/CustomSecurity"> 
     <xs:complexType> 
      <xs:annotation> 
       <xs:documentation>Specifies the behavior extension class applied to the endpoint.</xs:documentation> 
      </xs:annotation> 
      <xs:anyAttribute namespace="http://schemas.microsoft.com/XML-Document-Transform" processContents="strict" /> 
     </xs:complexType> 
    </xs:element> 
    <xs:element name="clientVia" vs:help="configuration/system.serviceModel/behaviors/endpointBehaviors/behavior/clientVia"> 
     <xs:complexType> 
      <xs:annotation> 
       <xs:documentation>Specifies the URI for which the transport channel should be created.</xs:documentation> 
      </xs:annotation> 
      <xs:attribute name="viaUri" type="xs:string" use="optional"> 
       <xs:annotation> 
        <xs:documentation>A string that specifies a URI that indicates the route a message should take.</xs:documentation> 
       </xs:annotation> 
      </xs:attribute> 
      <xs:attribute name="lockAttributes" type="xs:string" use="optional" /> 
      <xs:attribute name="lockAllAttributesExcept" type="xs:string" use="optional" /> 
      <xs:attribute name="lockElements" type="xs:string" use="optional" /> 
      <xs:attribute name="lockAllElementsExcept" type="xs:string" use="optional" /> 
      <xs:attribute name="lockItem" type="boolean_Type" use="optional" /> 
      <xs:anyAttribute namespace="http://schemas.microsoft.com/XML-Document-Transform" processContents="strict" /> 
     </xs:complexType> 
    </xs:element> 
संबंधित मुद्दे