Could not load file or assembly 'IBM.Data.DB2'
According to the IBM site, I set up a sample project where I have referenced the dll
IBM.Data.DB2
In the project I have the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using IBM.Data.DB2;
namespace TesteDB2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAbreConexao_Click(object sender, EventArgs e)
{
CriarDB2Conection();
}
protected void btnConsulta_Click(object sender, EventArgs e)
{
ReadMyData("Provider=IBMDADB2;Database=sample;HOSTNAME=db2host;PROTOCOL=TCPIP;PORT=50000;uid=myUserName;pwd=myPwd; ");
}
public void CriarDB2Conection()
{
string myConnString = "Provider=IBMDADB2;Database=sample;HOSTNAME=db2host;PROTOCOL=TCPIP;PORT=50000;uid=myUserName;pwd=myPwd; ";
DB2Connection myConnection = new DB2Connection(myConnString);
myConnection.Open();
MessageBox.Show("\nDatabase: " + myConnection.Database.ToString());
// MessageBox.Show("Versão do servidor: " + myConnection.ServerVersion
// + "\nDatabase: " + myConnection.Database.ToString());
myConnection.Close();
}
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT SALES, SALES_PERSON FROM SALES";
DB2Connection myConnection = new DB2Connection(myConnString);
DB2Command myCommand = new DB2Command(mySelectQuery, myConnection);
myConnection.Open();
DB2DataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read())
{
Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
}
// always call Close when done reading.
myReader.Close();
// Close the connection when done with it.
myConnection.Close();
}
}
}
Could not load file or assembly 'IBM.Data.DB2' or one of its dependencies. Unable to verify the strong name signature. Perhaps the assembly has been violated or delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
Description: An unhandled exception occurred during the execution of the current web request Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'IBM.Data.DB2' or one of its dependencies. Unable to verify the strong name signature. Perhaps the assembly has been violated or delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
I appreciate the help.