Type initializer threw exception

T

tshad

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
 
J

Jon Skeet [C# MVP]

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?

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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.
 
B

Ben Voigt [C++ MVP]

Ignacio Machin ( .NET/ C# MVP ) said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top