C# class library
-
Hi I am creating dll using C#. I made the research and little bit confused with following: 1) does all the classes need Guid? 2) Does all the class need interface classes? or can I have just regular class without interface and Guid? [Guid("....")] public interface myclass_interface { .... } [Guid("...."), ClassInterface(ClassInterfaceType.None)] public class myclass_class:myclass_interface { .. } 3) Can library have static function/procedures so other classes can call them directly? 4) Can I have a class, that will not be calling from COM client, without a guid? Thank you.
-
Hi I am creating dll using C#. I made the research and little bit confused with following: 1) does all the classes need Guid? 2) Does all the class need interface classes? or can I have just regular class without interface and Guid? [Guid("....")] public interface myclass_interface { .... } [Guid("...."), ClassInterface(ClassInterfaceType.None)] public class myclass_class:myclass_interface { .. } 3) Can library have static function/procedures so other classes can call them directly? 4) Can I have a class, that will not be calling from COM client, without a guid? Thank you.
pnpfriend wrote:
) does all the classes need Guid?
No. This is only needed if you are going to access the class from COM.
pnpfriend wrote:
- Does all the class need interface classes? or can I have just regular class without interface and Guid?
No, classes are not required to implement an interface. Interface essentially allow you to define the "contract" that the class will provide. It does nothing to ensure how that contract is implemented but only that specific methods/properties will be available.
pnpfriend wrote:
Can library have static function/procedures so other classes can call them directly?
The library can't, but an individual class can have static methods and/or properties that can be called without requiring an instance of that class.
pnpfriend wrote:
Can I have a class, that will not be calling from COM client, without a guid?
This is pretty much the same as question 1, just asked inversely...so yes, you can have a class that isn't called from COM without a GUID.
Scott. —In just two days, tomorrow will be yesterday. —Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[Forum Guidelines] [Articles] [Blog]