Error: Unable to load file or Assembly

Asked

Viewed 7,250 times

2

I am developing a desktop application with c#, and is giving the following error when I do some interaction with the Bank.

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in BackupRN.dll

Additional information: Não foi possível carregar arquivo ou assembly 'Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' ou uma de suas dependências. O sistema não pode encontrar o arquivo especificado.

More detailed.

System.IO.FileNotFoundException was unhandled
  HResult=-2147024894
  Message=Não foi possível carregar arquivo ou assembly 'Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' ou uma de suas dependências. O sistema não pode encontrar o arquivo especificado.
  Source=BackupRN
  FileName=Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
  FusionLog==== Informações sobre estado pré-associação ===
LOG: DisplayName = Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Glauco/OneDrive/Projects/ProjetoBackup/ProjetoBackup/bin/Debug/
LOG: PrivatePath inicial = NULL
Chamando assembly: Npgsql, Version=2.2.2.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7.
===
LOG: esta associação começa no contexto de carregamento default.
LOG: usando arquivo de configuração de aplicativo: C:\Users\Glauco\OneDrive\Projects\ProjetoBackup\ProjetoBackup\bin\Debug\SafeBackupConfig.exe.config
LOG: usando arquivo de configuração de host: 
LOG: usando arquivo de configuração da máquina de C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: referência pós-política: Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
LOG: a mesma associação foi vista antes e falhou com hr = 0x80070002.

  StackTrace:
       em BackupRN.ArquivoRN.buscar(Int32 idServidor) na c:\Users\Glauco\OneDrive\Projects\ProjetoBackup\BackupRN\ArquivoRN.cs:linha 40
       em Backup.frmPrincipal.btnTestar_Click(Object sender, EventArgs e) na c:\Users\Glauco\OneDrive\Projects\ProjetoBackup\ProjetoBackup\Principal.cs:linha 41
       em System.Windows.Forms.Control.OnClick(EventArgs e)
       em System.Windows.Forms.Button.OnClick(EventArgs e)
       em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       em System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       em System.Windows.Forms.Control.WndProc(Message& m)
       em System.Windows.Forms.ButtonBase.WndProc(Message& m)
       em System.Windows.Forms.Button.WndProc(Message& m)
       em System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       em System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       em System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       em System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       em System.Windows.Forms.Application.Run(Form mainForm)
       em Backup.Program.Main() na c:\Users\Glauco\OneDrive\Projects\ProjetoBackup\ProjetoBackup\Program.cs:linha 19
       em System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       em System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       em System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       em System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       em System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       em System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       em System.Activator.CreateInstance(ActivationContext activationContext)
       em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       em System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

Methods He misses the RN throw

public Arquivo buscar(int idServidor)
    {
    Arquivo banco = new Arquivo();
    try
        {
        //Valida informações a serem gravadas

        dao = new ArquivoDAO();

        banco = dao.buscar(idServidor);
        }
        catch (Exception e)
        {
        throw e;
        }
    return banco;
}

Metodo na DAO

public Arquivo buscar(int idServidor)
{
    try
    {
        DAOFactory dao = new DAOFactory();
        conexao = dao.CriaConexao();

        //String sql = "select max(id) from arquivo";
        //NpgsqlCommand sqlCon = new NpgsqlCommand(@sql, conexao);
        conexao.Open();

        //NpgsqlDataReader drCon;

        //drCon = sqlCon.ExecuteReader();

        //while (drCon.Read())
        //{
        Arquivo arquivo = new Arquivo();
        //arquivo.Id = Convert.ToInt32(drCon[0]);
        string sql2 = "select * from arquivo where idservidor = " + idServidor;
        NpgsqlCommand sqlCon2 = new NpgsqlCommand(@sql2, conexao);


        //drCon.Close();
        //conexao.Open();
        NpgsqlDataReader drCon2;
        drCon2 = sqlCon2.ExecuteReader(CommandBehavior.CloseConnection);

        while (drCon2.Read())
            {
            Arquivo arquivo2 = new Arquivo(Convert.ToInt32(drCon2[0]), drCon2[1].ToString(), Convert.ToInt32(drCon2[2]));
            drCon2.Close();
            return arquivo2;
            }
            //}

        Arquivo arquivo1 = new Arquivo(0, "", 0);
        return arquivo1;
    }
    catch (Exception erro)
    {
        Console.WriteLine("erro " + erro.Message);
        throw erro;
    }
}
  • You have the Mono.Security.dll next to the application? Post the method code that is giving error.

  • I put the methods.

  • You are complicating the error handling. Your code has a very common problem that can no longer happen. See: http://answall.com/a/30168/101 Follow the links of this answer and read through everything. There is plenty to read but it is of utmost importance that you understand how exceptions should be used. It is the opposite of what you are doing. Never capture an exception without doing anything useful. Never cast the exception again this way. "Never" capture Exception (read the texts to know when you can). It becomes more difficult to identify the problem in this way.

  • I’ll read this when I get home, just because of this mistake there’s no way you can help me? I need this urgently, I won’t have time to read it now. I debugged the project and it is stopping when it tries to establish the connection with the bank.

  • You’re hiding the real mistake. So it’s hard to tell what’s going on. But take a look at the file I told you about. If the message is correct it could be something related to it.

  • Okay, thanks, I’ll check here.

  • This error also appears. It has something to do with it. Undefined object reference for an instance of an object.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.