警告:类型库导出器遇到了从泛型类派生的类型并且未标记为 [ClassInterface(ClassInterfaceType.None)] [英] Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]

查看:84
本文介绍了警告:类型库导出器遇到了从泛型类派生的类型并且未标记为 [ClassInterface(ClassInterfaceType.None)]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个程序套件来连接到远程服务器并通过 WSDL 发送一些信息,这很成功并且工作正常,但是我被命令将我的所有程序移植到 DLL 中,我必须启用 COM 互操作并制作一些返回,我的大多数程序都运行良好,直到我在使用两个由 WSDL 制作的代理类的程序中发现此错误之前,我花了整整一周的时间阅读网络详细信息,但我不明白如何修复它,这是错误

Warning 1 类型库导出器警告处理Tarea.CrSeedService.CrSeedClient, Tarea".警告:类型库导出器遇到了从泛型类派生的类型,并且未标记为 [ClassInterface(ClassInterfaceType.None)].不能为此类类型公开类接口.考虑使用 [ClassInterface(ClassInterfaceType.None)] 标记类型,并使用 ComDefaultInterface 属性将显式接口公开为 COM 的默认接口.塔雷亚

这是出现错误的代理类之一

http://pastebin.com/y1zFfzER这是Service Reference的reference.cs文件

http://pastebin.com/vJuFZqsd

inb4 有些人将这个问题报告为重复我已经阅读了 是否可以使用 .NET 泛型类实现 COM 接口?但还是没看懂

如果您看到我已经在代理 cs 文件的所有类定义中添加的 pastebin,请执行以下操作

[ClassInterface(ClassInterfaceType.None)][ComSourceInterfaces(typeof(Procesos.Iclass1))]

哪里

 [ComVisible(true)]公共接口 Iclass1{string Ejecucion(string cn, string speed);}

其中 assemblyinfo.cs

[程序集:ComVisible(true)]

我该怎么办?我做错了什么?

我希望得到一些指导,VS2013 无法准确指导我错误在哪里虽然它手动说它的CrSeedService.CrSeedClient"我已经添加了定义但仍然输出错误.

[System.Diagnostics.DebuggerStepThroughAttribute()][System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")][ClassInterface(ClassInterfaceType.None)][ComSourceInterfaces(typeof(Procesos.Iclass1))]公共部分类 CrSeedClient : System.ServiceModel.ClientBase, Tarea.CrSeedService.CrSeed{废话}

问候

解决方案

我在我的解决方案资源管理器中找不到文件 reference.cs,但我可以通过搜索功能进入它(搜索class CrSeedClient")

http://puu.sh/g3Yv8/3e8f11c975.png

所以我添加了缺失的行,现在它可以正常工作了.

[ClassInterface(ClassInterfaceType.None)][ComSourceInterfaces(typeof(Procesos.Iclass1))]公共部分类 CrSeedClient

或者您可以编辑参考文件手动查找文件

http://puu.sh/g3YzU/8523948580.png

也许是我的错,称之为菜鸟错误,我不确定

I was making a program suite to connect to a remote server and send some information via WSDL, this was sucessful and working correctly, but i was ordered to port all my programs into DLL's, i had to enable COM interop and make some returns, most of my programs went fine, until i found this error in one of my programs who use two proxy classes made from a WSDL, i have spend a whole week reading on the web details, but i can't understand how to fix it, this is the error

Warning 1   Type library exporter warning processing 'Tarea.CrSeedService.CrSeedClient, Tarea'. Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute. Tarea    

This is one of the proxy classes who gets the error

http://pastebin.com/y1zFfzER and this is the reference.cs file of the Service Reference

http://pastebin.com/vJuFZqsd

inb4 some people report this question as duplicated I have readed Is it possible to implement a COM interface with a .NET generics class? but still didn't get it

if you see the pastebin i added already in all the classes definitions on the proxy cs file the following

[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(Procesos.Iclass1))]    

where

  [ComVisible(true)]
    public interface  Iclass1
    {
    string Ejecucion(string cn, string speed);
    }

where assemblyinfo.cs

[assembly: ComVisible(true)]

What should i do? What am i doing wrong?

I would appreciate some guidance, VS2013 can't guide me exactly on where is the error although it manually says its "CrSeedService.CrSeedClient" i have added the definitions and still outputs the mistake.

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(Procesos.Iclass1))]
public partial class CrSeedClient :        System.ServiceModel.ClientBase<Tarea.CrSeedService.CrSeed>,   Tarea.CrSeedService.CrSeed
{
blah
}

Regards

解决方案

I can't find the file reference.cs in my Solution Explorer, yet i can get into it via Search function (searching "class CrSeedClient")

http://puu.sh/g3Yv8/3e8f11c975.png

So I've added the missing lines and now it's working properly.

[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(Procesos.Iclass1))]
public partial class CrSeedClient

Alternatively you can edit the reference file finding the file manually

http://puu.sh/g3YzU/8523948580.png

maybe it's my fault, call it a rookie mistake, im not sure

这篇关于警告:类型库导出器遇到了从泛型类派生的类型并且未标记为 [ClassInterface(ClassInterfaceType.None)]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆