System.Activator.CreateInstance(Type type)抛出异常源:mscorlib

时间:2018-03-15 14:11:03

标签: c# exception windows-forms-designer

我有一个Windows窗体应用程序抛出此异常:

TargetSite:  System.Object CreateInstance(System.RuntimeType, Boolean, 
Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
Message: Exception has been thrown by the target of an invocation
Source: mscorlib

StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean 
publicOnly, Boolean noCheck, Boolean& canBeCached, 
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean 
skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean 
skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Pronet.Login.FrmLoginMetro.LoadMDI_Form()

这只发生在一台机器上,我有很多机器没有这个错误,所以我无法在开发机器上调试..

这是我的代码:

 void LoadMDI_Form()
    {
        try
        {
            Application.DoEvents();

            lblStatus.Text = "Carregando objetos do Banco...";
            lblStatus.Refresh();
            ((Form)Activator.CreateInstance(tipo)).Show();
            Hide();
        }
        catch (Exception ex)
        {
            MessageFactory.CreateMessage(EstiloMensagem.WindowsForm).ErroInesperado(ex, Perfil.CodUsuario, Perfil.NomeUsuario);
            Application.Exit();//fecha o sistema  
        }
    }

0 个答案:

没有答案