編輯:得到它排序,該表有外鍵沒有被解決。 Stackoverflow不會讓我發佈一個答案這個接近問這個問題ObjectContext實例已被處置,不能再用於需要連接的操作。 WCF與天藍色錯誤
我正在做一個Windows Phone應用程序,它從Windows Azure上的數據庫獲取信息,我使用WCF連接來做所以。
但是當我調試和本地調用我得到以下錯誤的服務:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
我使用的代碼,我改編自http://mobile.dzone.com/news/how-use-wcf-services-access-0(該LoginUser部分),從該網站的代碼工作正常,但,就像我說的那樣,我的原因是這個錯誤。
這裏是我的代碼:
public Product GetProduct(String Barcode)
{
string query = @"SELECT value Product FROM AzureDBEntities.Products AS Product WHERE Product.barcode = @Barcode";
ObjectParameter parameter = new ObjectParameter("Barcode", Barcode);
using (var context = new AzureDBEntities())
{
ObjectQuery<Product> results = context.CreateQuery<Product>(query, parameter);
foreach (Product result in results)
{
if (result != null)
{
return result;
}
}
}
return null;
}
任何想法我做了什麼錯?非常感謝。
什麼是堆棧跟蹤? – SLaks 2012-04-22 16:07:53
WCFServiceWebRole1.dll!WCFServiceWebRole1.Product.Producer1.get()第1028行+ 0x34字節 這是你需要的嗎? – IntSec 2012-04-22 16:21:31