Type initializer threw exception

  • Thread starter Thread starter tshad
  • Start date Start date
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
 
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
 
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.
 
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.
 
Back
Top