문제

I'm wondering for what the GUID in the AssemblyInfo.cs in C# Programs is: [assembly: Guid("a4df9f47-b2d9-49a9-b237-09220857c051")]

The commentary says it's for COM objects, but why do they need a GUID? Is the GUID accessibly externally?

So if it's only for COMs, do you need a GUID when you set [assembly: ComVisible(false)]?

도움이 되었습니까?

해결책

Guid (Globally unique identifier) is used to identify your component by outside world. When you write a project which is going to be used as COM (Component Object Model) you will have to give a unique name. For this reason you need to apply GUID attribute.

More info at http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.guidattribute.aspx

You can remove it if you won't be exposing it as COM on assembly level

다른 팁

All .Net assemblies have a GUID.

This attribute sets it; otherwise, it will be randomly generated by the compiler.

This GUID is by COM. If your assembly is ComVisible(true) then you need a stable GUID, otherwise the compiler will generate a random GUID. You will wonder why things work the first time, but stop working later! You would need to re-register the COM assembly every time with the new GUID.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top