Click here to Skip to main content
Sign Up to vote bad
good
See more: C#4.0partialAttributes, +
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 - 13:44

Comments
Sergey Alexandrovich Kryukov - 8 Oct '12 - 21:01
And why did you write DoSomething twice?! What tool? If this is your tool, write it correctly, that's it. --SA
YORENGOY - 8 Oct '12 - 22:34
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

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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 419
1 Mahesh Bailwal 373
2 Maciej Los 255
3 CPallini 175
4 Rohan Leuva 175
0 Sergey Alexandrovich Kryukov 9,287
1 OriginalGriff 7,204
2 CPallini 3,923
3 Rohan Leuva 3,211
4 Maciej Los 2,713


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid