Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 partial Attributes , +
How to add an attribute to a method declared on partial interface?
 
Ihave this code on a file
using System;
using System.Net.Security;
using WCF = global::System.ServiceModel;
 
namespace CMAWCF.ServiceContracts
{
    public partial interface IMyServiceServiceContract
    {
        [WCF::TransactionFlow(WCF::TransactionFlowOption.Mandatory)]
        void DoSomething(CMAWCF.MessageContracts.RequestDoSomething
                             request);
    }
}
 
and this code was generated by a tool on other file on the same project
using System;
using System.Net.Security;
using WCF = global::System.ServiceModel;
 
namespace CMAWCF.ServiceContracts
{
    public partial interface IMyServiceServiceContract
    {
        //... More methods
        [WCF::FaultContract(typeof(CMAWCF.FaultContracts.DefaultFaultContract))]
	[WCF::OperationContract(IsTerminating = false, IsInitiating =
        true, IsOneWay = false, AsyncPattern = false, Action = "DoSomething",
        ProtectionLevel = ProtectionLevel.None)]
        void DoSomething(CMAWCF.MessageContracts.RequestDoSomething
                             request);
        //... More methods
    }
}
 
But I got an error:
 
Type 'CMAWCF.ServiceContracts.IMyServiceServiceContract' already defines a member called 'DoSomething' with the same parameter types
 
How can I get an output like this:
 
using System;
using System.Net.Security;
using WCF = global::System.ServiceModel;
 
namespace CMAWCF.ServiceContracts
{
    public partial interface IMyServiceServiceContract
    {
        [WCF::TransactionFlow(WCF::TransactionFlowOption.Mandatory)]
        [WCF::FaultContract(typeof(CMAWCF.FaultContracts.DefaultFaultContract))]
	[WCF::OperationContract(IsTerminating = false, IsInitiating =
        true, IsOneWay = false, AsyncPattern = false, Action = "DoSomething",
        ProtectionLevel = ProtectionLevel.None)]
        void DoSomething(CMAWCF.MessageContracts.RequestDoSomething
                             request);
    }
}
 
I found some discussion about it, but nothing solid. Any idea? thanks in advance.
Posted 8-Oct-12 14:44pm
Comments
Sergey Alexandrovich Kryukov at 8-Oct-12 21:01pm
   
And why did you write DoSomething twice?! What tool? If this is your tool, write it correctly, that's it.
--SA
YORENGOY at 8-Oct-12 22:34pm
   
I´m using Web Service Software Factory 2010 and I want to implement transactions,so I need to add the attribute [WCF::TransactionFlow(WCF::TransactionFlowOption.Mandatory)]; If this attribute is added to the service contract each time the code is generated, the changes will be loss

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This problem has nothing to do with attributes or… it does not have to do with anything. Partial syntax is not very much of syntax; it's something very simple, used to define some type in two or more fragments of text of the code, typically in different files. And nothing else. It does not allow you to repeat any declaration. Your method should be declared only once, with the attribute. If this is your tool, fix it. If not, do not use it, or, in worst case, around by using it only where it works correctly.
 
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 205
1 Richard MacCutchan 185
2 DamithSL 170
3 Tomas Takac 146
4 OriginalGriff 132
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100