Hi,
This behavior is as per the language specs.
'System.ApplicationException' is a checked exception.
Static initializer or static field must not result in checked exception.
If one does, a compile time error occurs.
The workaround can by using explicit try catch blocks inside the static
function.
-Gijo Varghese
Visual J# Product Team.
--------------------
[quoted text, click to view] >Content-Class: urn:content-classes:message
>From: "Abc" <anonymous@discussions.microsoft.com>
>Sender: "Abc" <anonymous@discussions.microsoft.com>
>Subject: throws
>Date: Mon, 22 Dec 2003 00:25:40 -0800
>Lines: 8
>Message-ID: <01b301c3c865$2f134530$a001280a@phx.gbl>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Thread-Index: AcPIZS8TQKzL6lkwQ0SsRMx4cG81xA==
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Newsgroups: microsoft.public.dotnet.vjsharp
>Path: cpmsftngxa07.phx.gbl
>Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.vjsharp:5048
>NNTP-Posting-Host: tk2msftngxa08.phx.gbl 10.40.1.160
>X-Tomcat-NG: microsoft.public.dotnet.vjsharp
>
>How to use throws clause in static functions in j#.
> I got following error when trying to use that in a
>static function.
>'System.ApplicationException' cannot be thrown by static
>initializer or static field initializer
>
>
>Thanks
>
---------------------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.