Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Revit加载项调用Enity Framework方法会导致NotSupportedException_C#_Entity Framework_Revit Api_Revit_Notsupportedexception - Fatal编程技术网

C# 从Revit加载项调用Enity Framework方法会导致NotSupportedException

C# 从Revit加载项调用Enity Framework方法会导致NotSupportedException,c#,entity-framework,revit-api,revit,notsupportedexception,C#,Entity Framework,Revit Api,Revit,Notsupportedexception,我首先在RevitAddin项目中使用实体框架代码创建了ADO.NET实体数据模型 public static class ElevationDao { public static int GetId(int length) { var db = new DbContext(); var obj = db.Elevations.Where(x => x.Value == length); if (obj.Count()

我首先在
RevitAddin
项目中使用实体框架代码创建了ADO.NET实体数据模型

public static  class ElevationDao
{
    public static int GetId(int length)
    {
        var db = new DbContext();

        var obj = db.Elevations.Where(x => x.Value == length);

        if (obj.Count() == 0) 
           throw new Exception();

        return obj.First().ID;
    }
}
我在Revit命令的
Execute
方法中调用此函数:

[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        int id = ElevationDao.GetId(3300);
        return Result.Succeeded;
    }
}
执行此命令时,Revit会抛出一个
NotSupportException
,并自动关闭其会话

谁能解释一下,给我一个提示?多谢各位

附言:它只发生在我的笔记本电脑上,在我公司的电脑上,工作正常


我可以知道您是否已将库的引用添加到解决方案中吗?请查看解决方案资源管理器中的“参考资料”。亲爱的MatrixTai,我已将Library添加到我的项目中(使用Nugget),在控制台项目中工作正常。NET对从远程(网络)位置而不是本地计算机加载的DLL持怀疑态度。您是否正在使用此DLL或任何引用的DLL执行任何操作,以使其从网络驱动器加载引用的DLL?我在GitHub上同步了该项目。我已经通过重新安装Revit 2018:)修复了它。使用Revit时可能会出现错误。无论如何,谢谢你。