none
System.TypeInitializationException was unhandled RRS feed

  • General discussion

  • This project was running perfectly well in VS 2008 and 2010 as well (when I imported it from 2008).

    However, for some reasons, I had to recreate the project from scratch in VS2010 and I did it by carefully importing each of the individual files, classes, reports, etc, from 2008 project folder.

    Now, when I almost got through everything and try to execute it, I get the following error. Can anyone kindly help?

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

    System.TypeInitializationException was unhandled
      Message=The type initializer for 'EPM1._0.clsParameters' threw an exception.
      Source=EPM1.0
      TypeName=EPM1._0.clsParameters
      StackTrace:
           at EPM1._0.frmLogin.cmdSubmit_Click(Object sender, EventArgs e) in D:\test\EPM1.0\frmLogin.vb:line 26
           at EPM1._0.frmLogin.txtPassword_KeyDown(Object sender, KeyEventArgs e) in D:\test\EPM1.0\frmLogin.vb:line 90
           at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
           at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
           at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
           at System.Windows.Forms.TextBox.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.RunDialog(Form form)
           at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
           at System.Windows.Forms.Form.ShowDialog()
           at EPM1._0.MDIParent.MDIParent_Load(Object sender, EventArgs e) in D:\test\EPM1.0\MDIParent.vb:line 124
           at System.EventHandler.Invoke(Object sender, EventArgs e)
           at System.Windows.Forms.Form.OnLoad(EventArgs e)
           at System.Windows.Forms.Form.OnCreateControl()
           at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
           at System.Windows.Forms.Control.CreateControl()
           at System.Windows.Forms.Control.WmShowWindow(Message& m)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at System.Windows.Forms.Form.WmShowWindow(Message& m)
           at System.Windows.Forms.Form.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)
           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Control.set_Visible(Boolean value)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(ApplicationContext context)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           at EPM1._0.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
           at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
           at System.Activator.CreateInstance(ActivationContext activationContext)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.MethodAccessException
           Message=Attempt by security transparent method 'EPM1._0.clsParameters..cctor()' to access security critical method 'Microsoft.VisualBasic.FileSystem.CurDir()' failed.

    Assembly 'EPM1.0, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model.  Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
           Source=EPM1.0
           StackTrace:
                at EPM1._0.clsParameters..cctor() in D:\test\EPM1.0\clsParameters.vb:line 461
           InnerException:

    Thursday, May 26, 2011 6:02 PM

All replies