Hi Ali,
Thank you for using MSDN Newsgroup! My name is Jeffrey, and I will be
assisting you on this issue.
From your discussion in this post, I think you need static constructor to
initialize the static members. Yes, just as Jon states, your class's static
constructor will not be called when application start(Unless you refer the
class member or instance when Application's initialize). A static
constructor is called automatically to initialize the class before the
first instance is created or any static members are referenced.
====================
Please refer to the MSDN static constructor document:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
vclrfStaticConstructors.asp
In it Remarks part, you will find:
1). A static constructor does not take access modifiers or have parameters.
2). A static constructor cannot be called directly.
3).The user has no control on when the static constructor is executed in
the program.
So when you specify an access modifier, you will get " access modifiers are
not allowed on static constructors" error. This is almost the same as
normal instance constructor.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.