Am getting 'System.TypeInitializationException' exception in preinit method while running provider hosted app on premise solution from visual studio 2013.

Thanks in advance

1 Answer 1


TypeInitializationException is thrown when a static constructor throws an exception or when you try to access a class where the static constructor threw an exception.

Look into it's InnerException property as that holds the details on the actual exception that is thrown.

  • Getting exception in TokenHelper.GetS2SClientContextwithWindowsIdenitty(hostweb, request.logonidentity)
    – user41938
    Commented May 5, 2015 at 11:04
  • @user41938 That usually means something went wrong with the handshake between the site and the app. The solution depends on what type of authentication you use (windows, adfs, fba etc.)
    – user2536
    Commented May 5, 2015 at 11:18
  • Am usin windows authetication
    – user41938
    Commented May 5, 2015 at 11:20
  • App is deployed to Host web when am clicking the app it needs to redirect to remote web during that time am getting this exception
    – user41938
    Commented May 5, 2015 at 11:21
  • My remote web is in Sharepoint-80 site and host web is in different port. In IIs If i try to browse default.aspx page am getting the same exception without running the solution in VS
    – user41938
    Commented May 5, 2015 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.