none
The type initializer for 'System.Net.ComNetOS' threw an exception

    Question

  • i am still facing this problem "The type initializer for 'System.Net.ComNetOS' threw an exception" after i convert solution from framework V2.0 to V4.0 in vb.net 2010 ultimate.

    i checked even the App.Config too ,all things is right .i will copy the full error message :

    ---------------------------------------------------------------------------------------------

    System.TypeInitializationException was unhandled
      Message=The type initializer for 'System.Net.ComNetOS' threw an exception. 
     Source=System   TypeName=System.Net.ComNetOS
      StackTrace:
           at System.Net.Sockets.Socket.InitializeSockets()
           at System.Net.Sockets.Socket.get_OSSupportsIPv4()
           at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider, IAuthorizeRemotingConnection authorizeCallback)
           at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.RegisterChannel(ChannelType ChannelType, Boolean ChannelIsSecure)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

    ------------------------------------------------------------------------

    please , anyone can help me on this.? i am waitting !

    Wednesday, February 15, 2012 1:40 PM

All replies

  • You can try rebuilding the application with a new version number and see whether it makes difference.

    DeVa, M.S., {MSFT} Please remember to mark the replies as answers if they help

    Friday, February 17, 2012 7:01 PM
  • thanks Deva for your replay ..

    Rebuild All Succeeded but in the time or run  this message is apeare "The type initializer for 'System.Net.ComNetOS' threw an exception" .

    i converted all application to 4.0 ,but only in the time of run i am facing that problem ... please help.

    Saturday, February 18, 2012 10:57 AM
  • after long RnD , it's solved after i remove the following code from app.config :

    <startup  useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
      </startup>

    but in other project inside my solution i am start to face same problem before.

    i am sure that all projects are converted successfully to v4.0



    • Edited by FVBS Saturday, February 18, 2012 12:42 PM
    Saturday, February 18, 2012 12:21 PM
  • Checking the app.config will be the key in these type of scenarios. You can also try comparing the migrated project app.config with newly created project's app.config and see the difference. Finally, you can give a tryby rebuilding the application with new version numbers...


    DeVa, M.S., {MSFT} Please remember to mark the replies as answers if they help

    Thursday, February 23, 2012 4:35 AM