我想用我的语境的对象在using语句。它适用于一个项目,但是在另外一个,我得到了下面的错误。
'...':在使用语句中使用的类型必须是隐式转换 为System.IDisposable的
当我指的是语境的对象,我指的是,当你正在使用的LINQ to SQL自动创建的对象。
我在工作的类,实现了另一个接口,莫非是搞砸了这个上下文对象?
使用(TGDC上下文=新TGDC())
{
}
字
使用
有红色下它(错误)squigly行。
解决方案
您应该添加的引用将System.Data.Linq
。我怀疑这是个问题。
I'm trying to use my 'context' object in a using statement. It works on one project, but on another, I'm getting the following error.
'...': type used in a using statement must be implicitly convertible to 'System.IDisposable'
When I'm referring to the 'context' object, I'm referring to the object automatically created when you're working with LINQ to SQL.
The class I'm working within, implements another interface, could that be screwing up this context object?
using (TGDC context = new TGDC())
{
}
the word
using
has the red squigly line under it (error).
解决方案You should add a reference to System.Data.Linq
. I suspect that's the issue.