首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以从哪里获得GUID值用于创建DLL、C#的接口和类

问我可以从哪里获得GUID值用于创建DLL、C#的接口和类
EN

Stack Overflow用户
提问于 2011-09-09 22:05:59
回答 2查看 5.5K关注 0票数 6

我可以从哪里获得用于在C#中创建动态链接库的接口和类的GUID值?我使用的是Viusal 2005。请帮助我。?

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Wrapper
{
[Guid("")] => Where can i get this???
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface _Service
{
    [DispId(1)]
    SearchResponse ExecuteSearch();
}

[Guid("")] => Where can i get this???
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Wrapper.Service")]
public class Ebil : _Service
{
FactService ew;

    public Ebil()
    {
        ew = new FactService();

    }

    public SearchResponse ExecuteSearch(SearchRequest searchRequest)
    {
        return ew.ExecuteSearch(searchRequest);
    }

}}

EN

回答 2

Stack Overflow用户

发布于 2011-09-09 22:07:50

使用您选择的GUID生成器或follow this link。

GuidAttribute Class

当不需要自动GUID时提供显式System.Guid。

它只需要与Guid类的构造函数兼容:

传递给特性的字符串的格式必须是类型Guid可接受的构造函数参数。若要避免与类型Guid冲突,请显式使用长名称GuidAttribute。仅当类型必须具有特定的GUID时才使用显式GUID。如果省略该属性,则会自动分配GUID。

票数 5
EN

Stack Overflow用户

发布于 2011-09-09 22:13:46

Type类的GUID属性。试一试

代码语言:javascript
复制
typeof(_Service).GUID;
typeof(Ebil).GUID;
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7362890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档