Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Type initializer threw exception

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tshad - 06 Feb 2008 11:38 GMT
I got the following error message when I had set a static string value to ""
or " ";

"The type initializer for "theSettings" threw an exception."
"The path is not of a legal form."

The variable is set as:

private static string logFilePath;

In a static function.

If I set logFilePath to "a", I have no problem.

What would cause this problem?

Thanks,

Tom
Jon Skeet [C# MVP] - 06 Feb 2008 11:49 GMT
> I got the following error message when I had set a static string value to ""
> or " ";
[quoted text clipped - 11 lines]
>
> What would cause this problem?

That entirely depends on what the type initializer for
"theSettings" (why the awful type name btw?) does.

I'm sure there's more to it than just a variable...

Jon
Ignacio Machin ( .NET/ C# MVP ) - 06 Feb 2008 16:18 GMT
HI,

Without more details we cannot help you. In my experience you see this kind
of exception when a constructor throw an unhandle exception. Most of the
time the InnerException will contain the "real" exception.

Signature

Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

>I got the following error message when I had set a static string value to
>"" or " ";
[quoted text clipped - 15 lines]
>
> Tom
Ben Voigt [C++ MVP] - 06 Feb 2008 17:39 GMT
> HI,
>
> Without more details we cannot help you. In my experience you see this
> kind of exception when a constructor throw an unhandle exception. Most of
> the time the InnerException will contain the "real" exception.

IIRC, it's not InnerException in this case but the LoaderExceptions
collection... and there doesn't seem to be any general way to dump all
information associated to the exception, you have to special case things
like this.

Maybe if Microsoft had tried to make the designer show useful information
when an exception occurs, they'd have realized the problem.

>>I got the following error message when I had set a static string value to
>>"" or " ";
[quoted text clipped - 15 lines]
>>
>> Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.