我有一个大型对象结构,希望在 .Net4 后端和 Silverlight 5 前端之间共享。我创建了两个适当类型的类库项目,并在 .Net 库中实现了我的对象结构,并链接到 SL 库。在 Silverlight 客户端,我引用了 Silverlight 类库。当我生成服务引用时,我选中了“重用引用程序集中的类型”选项。但是,当我生成服务引用时,我发现引用的程序集中的类型仍在生成。它只是某些类型,并且似乎主要是集合类型(归因于
)。
我有一个主对象,它有许多属性,通常是 List
或在某些情况下它们是 MyListTypeB
,其中 MyListTypeB
继承自列表
。似乎是类似于 MyListTypeB 的类导致生成代理。这些都由
赋予属性,并具有默认构造函数。
我还发现,即使我添加服务引用的项目引用了包含实体的其他 SL 项目,当我更新服务时,也会直接创建对 dll 的新引用添加到项目中。我不确定为什么会发生这种情况,或者它是否会导致服务代理生成中的混乱
是否有任何方法可以告诉哪些类/属性导致服务生成生成代理类?或者这是一个反复试验的情况,必须注释掉属性,直到它们没有生成并磨练问题类?
I have a large object structure that I'm wanting to share between a .Net4 backend and a Silverlight 5 front end. I've created two class library projects of the appropriate type, and have my object structure implemented in the .Net library, and linked into the SL library. On the Silverlight client side I am referencing the Silverlight class library. When I generate the service reference I have checked the option to "Reuse types in referenced assemblies". However when I generate the service reference I am finding that types that are in referenced assemblies are still being generated. It is only certain types, and appears to be largely collection types (attributed with <CollectionDataContract>
).
I have a main object that has many properties which are generally either List<MyTypeA>
or in some cases they are MyListTypeB
, where MyListTypeB
inherits from List<MyTypeB>
. It seems to be the classes similar to MyListTypeB
that are causing the proxies to be generated. These are all attributed with <CollectionDataContract>
and have a default constructor.
I also find that even though the project where I am adding the service reference to has a reference to the other SL project containing the entities, when I update the service a new reference directly to the dll is also being added to the project. I'm not sure why this is happening, or if it is causing confusion in the service proxy generation
Is there any way to tell what classes/properties are causing the service generation to generate proxy classes? Or is it a case of trial and error having to comment out attributes until they aren't generated and hone in on the problem class?
发布评论
评论(1)
我现在已经了解了 svcmap 文件的使用,并更新了 CollecitonMappings 元素以包含我的集合类型,如下所述:
http://mostlydevelopers.com/blog/post/2009/12/14/Configure-WCF-Service-ndash3b-Reuse-Collection-Types-Issue.aspx
看起来有点不寻常svcmap 功能是如此没有文档记录。
我能够在 svcmap 文件中添加类似于以下内容的条目:
然后,当我更新服务引用时,不会生成代理集合。
I have now found out about the use of the svcmap file, and updating the CollecitonMappings elements to include my collection types, described here:
http://mostlydevelopers.com/blog/post/2009/12/14/Configure-WCF-Service-ndash3b-Reuse-Collection-Types-Issue.aspx
It seems a little unusual that the svcmap functionality is so undocumented.
I was able to add an entry int he svcmap file similar to the following:
And then when I updated the service reference the proxy collections are not generated.