c# - Dapper called in application, and called in DLL is throwing a MissingMethodException -
i'm wondering why application referencing dll created uses dapper failing. method not found: 'system.collections.generic.ienumerable'1<!!0> dapper.sqlmapper.query(system.data.idbconnection, system.string, system.object)'. error message. when track down offending code appears in dotpdfinvoidelayout.dll @ invoicemanager.loaddata() here below code method failing, because i'm calling dll, stack trace points last curly brace of method. line 1988. assuming real problem line makes call 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 * trims.dbo.trimnameaddressmaster 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 console application dotpdfinvoicelayout runs fine. removed main() , changed project properties run class library copied generated dll bin of web application , referenced dll in web project.
i've tried make sure both using same version of dapper.
this sounds 1 of projects referencing down-level 3.5 library, , 1 referencing up-level 4.0/4.5 library. intentioanally have .net 3.5 project configured use c# 3.0 syntax - although in ways legacy thing "back in day" when dapper deployed code file rather assembly. consequence of using c# 3.0, doesn't have same level of support optional parameters, uses overloads instead. these overloads have never existed in 4.0/4.5 library. due this, 3.5 project not directly interchangeable 4.0 project.
change projects both targeting same .net level in terms of "dapper", , should work.
Comments
Post a Comment