admin管理员组文章数量:1405393
I'm new to working with WCF. I'm currently at the point where I'm implementing the MessageContactAttribute
. This class is located in its own separate project and referenced when needed.
[MessageContract(IsWrapped = true, WrapperName = "JournalTransactionRequestObject",
WrapperNamespace = "/")]
public class JournalTransactionRequestInfo : IJournalTransactionRequestInfo
{
[MessageHeader(Namespace = "/")]
public string LicenseKey { get; set; }
}
The service is currently hosted by a console app and it seems to run fine. My problem is in the client. When I generate the service proxy, it creates its own JournalTransactionRequestInfo
class as opposed to referencing the already existing one.
Is there a way I could make the client reference the class that I made specifically? I don't seem to have this problem with the DataContact
attribute. I've checked the 'Reuse types in all referenced assemblies' option in the configuration.
Am I missing anything?
I'm new to working with WCF. I'm currently at the point where I'm implementing the MessageContactAttribute
. This class is located in its own separate project and referenced when needed.
[MessageContract(IsWrapped = true, WrapperName = "JournalTransactionRequestObject",
WrapperNamespace = "https://www.something/")]
public class JournalTransactionRequestInfo : IJournalTransactionRequestInfo
{
[MessageHeader(Namespace = "https://www.something/")]
public string LicenseKey { get; set; }
}
The service is currently hosted by a console app and it seems to run fine. My problem is in the client. When I generate the service proxy, it creates its own JournalTransactionRequestInfo
class as opposed to referencing the already existing one.
Is there a way I could make the client reference the class that I made specifically? I don't seem to have this problem with the DataContact
attribute. I've checked the 'Reuse types in all referenced assemblies' option in the configuration.
Am I missing anything?
Share Improve this question asked Mar 23 at 19:23 TimTim 457 bronze badges1 Answer
Reset to default 0Make sure your client project references the assembly that contains your JournalTransactionRequestInfo class (and any other shared contracts). This ensures the client get the class you want to reuse.
You can also try adding a service reference using VS by following these steps :
In your client project, right-click on the project and choose Add Service Reference.
Enter the service URL and click Go.
Before clicking OK, click the Advanced… button.
In the Advanced Settings dialog, locate the Reuse types in referenced assemblies option.
Ensure that your shared contract assembly is referenced by the client and that it appears in the list of assemblies to reuse types from. Check the box to reuse types found in these assemblies.
本文标签: cCan I reference a MessageContract as a reuse typeStack Overflow
版权声明:本文标题:c# - Can I reference a MessageContract as a reuse type? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744271676a2598213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论