开发者

Make enum imported from WCF as visible in COM Interop

I have several WCF services that 开发者_开发知识库I have imported into a .Net4 Class Library. When the proxy is created, several enumerators that are declared as DataContracts are imported into the proxy. I later expose several procedures through COM Interop to be used as ActiveX libraries, and I use the imported enumerators as parameters on these procedures.

In the procedures of my Class Library, I can expose with [ComVisible(true)], so that they can be called through COM. However, the methods that have enumerators as parameters, when I register with regasm.exe, I get the error:

Type library exporter warning processing 'xxxxxx.Method(pEnumerator),yyyyyy'. Warning: Non COM visible value type 'yyyyyy.zzzzzzz.enEnumerator' is being referenced either from the type currently being exported or from one of its base types.

I know this happens because the enumerators aren't exposed with ComVisible, but if I put the necessary parameter, since they are in the proxy, anytime I refreshed the proxy, they will be overwritten. Is there anyway around this?

I can create my own enumerators inside the Class Library, expose them with ComVisible, and do a switch to match the imported enumerators to my created enumerators. But I would like to avoid this.

Tks for the help


Create a common library that is shared between client and service. Add your enumerators in that assembly and mark them with ComVisible.

While creating proxy from VS, there is a checkbox (checked by default) which allows reusing types in current or referenced assemblies. With this checked, proxy will use types from shared assembly instead of generating new ones.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜