I'm wondering why my application that is referencing a dll I created that also uses Dapper is failing.
I get a Method not found: 'System.Collections.Generic.IEnumerable'1<!!0> Dapper.SqlMapper.Query(System.Data.IDbConnection, System.String, System.Object)'. error message.
When I track this down to the offending code it appears to be in DotPdfInvoideLayout.dll @ InvoiceManager.LoadData()
Here below is the code for the method that is failing, because I'm calling this as a dll, the Stack Trace points to the last curly brace of the method. Line 1988. I am assuming that my real problem is the line that makes the call to Query()
public void loadData(IEnumerable<IPdfRenderable> textBoxes)
{
var conn = new SqlConnection("Server=something;DataBase=TRIMS;UID=user;Password=password;");
var output = conn.Query<TRIMNameAddressMaster>("Select top 1 * from Trims.dbo.TRIMNAMEADDRESSMASTER where id = '" + _transaction.strap + "'", null).FirstOrDefault();
var type = output.GetType();
var properties = type.GetProperties();
var r = new System.Text.RegularExpressions.Regex(@"((?<=\{)[^}]*(?=\}))+");
foreach (var textbox in textBoxes)
{
var matches = r.Matches(((PdfTextBox)textbox).Text);
foreach (Match match in matches)
{
try
{
var p = properties.Single(pi => pi.Name.ToLower() == match.Value.ToLower());
((PdfTextBox)textbox).Text = ((PdfTextBox)textbox).Text.Replace(
"{" + match.Value + "}", (p.GetValue(output, null) ?? string.Empty).ToString());
}
catch (Exception ex)
{
Console.WriteLine("No Mapping occurred" + match.Value);
}
}
}
}
As a console application DotPdfInvoiceLayout runs perfectly fine.
I removed the Main() and changed the project properties to run this as a Class Library then copied the
generated dll into the bin of my web application and referenced the dll in the web project.
I've tried to make sure both are using the same version of Dapper.