2

私が作成した Dapper も使用する dll を参照している私のアプリケーションがなぜ失敗するのか疑問に思っています。Method not found: 'System.Collections.Generic.IEnumerable'1<!!0> Dapper.SqlMapper.Query(System.Data.IDbConnection, System.String, System.Object)'.エラーメッセージが表示されます。これを問題のコードまで追跡すると、DotPdfInvoideLayout.dll にあるように見えます @InvoiceManager.LoadData() 以下は、失敗しているメソッドのコードです。これを dll として呼び出しているため、スタック トレースは最後の中括弧を指していますメソッド。Line 1988. 私の本当の問題は、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);
            } 
        }

    }
}

コンソール アプリケーションとしてはDotPdfInvoiceLayout問題なく動作します。Main() を削除し、プロジェクト プロパティを変更してこれをクラス ライブラリとして実行し、生成された dll を Web アプリケーションのビンにコピーし、Web プロジェクトで dll を参照しました。

両方が同じバージョンの Dapper を使用していることを確認しようとしました。

4

1 に答える 1