繁体   English   中英

dapper rainbow MissingMethodException

[英]dapper rainbow MissingMethodException

为什么我会得到这个例外? 代码不一样,但接近'demo'https: //gist.github.com/1599013

例外:MissingMethodException

说明:

找不到方法:'System.Collections.Generic.IEnumerable 1<System.Object> Dapper.SqlMapper.Query(System.Data.IDbConnection, System.String, System.Object, System.Data.IDbTransaction, Boolean, System.Nullable 1 ,System.Nullable`1)'。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using Dapper;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;

namespace daconsole2
{
    class Program
    {
        class Product
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public string Description { get; set; }
            public DateTime? LastPurchase { get; set; }
        }

        // container with all the tables
        class MyDatabase : Database<MyDatabase>
        {
            public Table<Product> Products { get; set; }
        }
        //*/
        static void Main(string[] args)
        {
            var cnn = new MySqlConnection("uid=name;pwd=pw;Port=3306;database=test");
            cnn.Open();
            var db = MyDatabase.Init(cnn, commandTimeout: 2);
            //if(false)
            db.Execute(@"create table Products (
Id int primary key,
Name varchar(20),
Description TEXT,
LastPurchase datetime)");
            var productId = db.Products.Insert(new { Name = "Hello", Description = "Nothing" });
            //var db = cnn;
            Console.ReadKey();
        }
    }
}

我们遇到了同样的问题,结果是解决方案中的一些项目引用了不同版本的Dapper。 例如,一个项目使用了在“属性”窗口中显示v4.0.30319的运行时版本。 另一个项目的Dapper运行时版本为v2.0.50727(.NET 3.5)。

一旦我将它们全部设置为v2.0.50727版本,此错误就会消失。

*应该注意的是,它们都显示了文件版本1.12.0.0,因此这不是一种可靠的方式来区分它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM