The type initializer for "HeaderEncoding" threw an exception

T

TopBanana

Hi

I wonder if anyone has seen this before?

I have two machines running exactly the same code. On the first, it
works perfectly, on the second I get the TypeInitializationException
'The type initializer for "HeaderEncoding" threw an exception'.

I am using an HttpWebRequest, and the exception occurs when I flush my
input to the RequestStream.

I have tried reinstalling the dotnet fx, but to no avail.

Thanks
 
W

Walter Wang [MSFT]

Hi,

Thank you for your post.

Would you please telling me the call stack when the exception is thrown?

Also, since this problem is environment specific, you can use some http
trace tool such as Fiddler to check the http request details on different
machines. You can find Fiddler here: http://www.fiddlertool.com/fiddler/

I'm looking forward to your findings so that we can continue the
troubleshooting. Thanks.



Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

TopBanana

Would you please telling me the call stack when the exception is thrown?

Also, since this problem is environment specific, you can use some http
trace tool such as Fiddler to check the http request details on different
machines. You can find Fiddler here: http://www.fiddlertool.com/fiddler/

Hi Walter. Thanks for your reply.

Interesting, Fiddler threw the exact same exception on startup, and
here is a copy of the dialog:

---------------------------
Sorry, you've found a bug.
---------------------------
Fiddler has encountered an unexpected problem. If you believe this is
a bug in Fiddler, please copy this message by hitting CTRL+C, and
submit a bug report using the Help | Send Feedback menu.
Unable to create a transport connection.
at System.Net.Connection.StartConnectionCallback(Object state,
Boolean wasSignalled)
System.TypeInitializationException: The type initializer for
"HeaderEncoding" threw an exception. ---> System.ArgumentException:
Invalid or unsupported code page type.
at System.Text.CodePageEncoding.GetCPMaxCharSizeNative(Int32
codePage)
at System.Text.CodePageEncoding..ctor(Int32 codepage)
at System.Text.Encoding.GetEncodingRare(Int32 codepage)
at System.Text.Encoding.GetEncoding(Int32 codepage)
at System.Net.HeaderEncoding..cctor()
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.MakeRequest()
at System.Net.HttpWebRequest.EndSubmitRequest()
at System.Net.HttpWebRequest.SetRequestSubmitDone(ConnectStream
submitStream)
at System.Net.Connection.StartConnectionCallback(Object state,
Boolean wasSignalled) Fiddler v1.2.0.0
 
W

Walter Wang [MSFT]

Hi James,

Thank you for your quick reply.

From the call stack of the exception, the exception is raised while getting
an Encoding. It's rather strange that it will fail.

Could you please check the version of installed .NET Framework? You can use
method described here:

#How to determine which versions of the .NET Framework
http://support.microsoft.com/default.aspx?kbid=318785

Please follow the steps described in the KB to check your two machines'
installed .NET Framework version and see if they're different. From
Fiddler's requirements, it requires v1.1 (4322).
--
Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

TopBanana

From the call stack of the exception, the exception is raised while getting
an Encoding. It's rather strange that it will fail.

Could you please check the version of installed .NET Framework?

Hi Walter,

Yes it does seem strange that it should fail. I've googled the
problem and it seems some other people have seen it too.

The mscorlib version is 1.1.4322.2032 (1.1 sp1)

Thanks
- James
 
W

Walter Wang [MSFT]

Hi James,

Thank you for your update.

From a similar case, I found one possible cause of this issue:

Missing registry key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
"28591"="c_28591.nls"

I've tested on my machine by removing the registry value and run Fiddler,
it does show the exception as you described. So it's very likely the cause
of your issue too, please let me know if this works or not. Thanks.

Hope this helps. Please feel free to post here if anything is unclear.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

TopBanana

From a similar case, I found one possible cause of this issue:

Missing registry key
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
"28591"="c_28591.nls"

I've tested on my machine by removing the registry value and run Fiddler,
it does show the exception as you described. So it's very likely the cause
of your issue too, please let me know if this works or not. Thanks.

Hi Walter,

Unfortuantely it looks like that key is present in the registry.

Any other ideas? Could it be looking for a differnt codepage for some
reason?

Thanks
 
W

Walter Wang [MSFT]

Hi,

Thank you for your update.

Since you've mentioned one of your two machines is running the application
correctly, I recommend you export the registry key and compare these two
exported files to see if there're any difference.

I'm looking forward to your findings.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

TopBanana

Since you've mentioned one of your two machines is running the application
correctly, I recommend you export the registry key and compare these two
exported files to see if there're any difference.

Hi Walter,

The entire codepage key on both machines is identical.

- James
 
W

Walter Wang [MSFT]

Hi James,

Thank you for your update.

From the internal log of the possible cause, such cause will need live
debugging or dump analysis to find out. Unfortunately that's out of
newsgroup support scope. Issues of this nature are best handled working
with a dedicated Microsoft Support Engineer by contacting Microsoft
Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

TopBanana

From the internal log of the possible cause, such cause will need live
debugging or dump analysis to find out. Unfortunately that's out of
newsgroup support scope.

OK Walter I will set something up with the support group.

Thanks for your assistance so far, you've been very helpful.
 
W

Walter Wang [MSFT]

Thank you for your understanding.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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