私は新しいプロジェクトを開始しました。 DB名前空間の下にEFアイテムを追加したクラスライブラリを作成し、WSで公開可能な各エンティティのクラス(Stripped down)を作成します。私はCLをWindowsのテストアプリケーションですべてが動作していたかどうかを確認しました。それで、私はWSの参照を追加してEFの接続文字列を追加し、各エンティティごとに作成したオブジェクトをretrunするwebmethodを作成しました。EFとWebサービスエラー "System.InvalidOperationException"
ので、私のnamspacesこの
[プロジェクト名] .CL.Itemのように見える - 作成したオブジェクト [プロジェクト名] .CL.DB.Item - Efのアイテム [プロジェクト名] .WS - Webサービスの名前空間
だから私はwsを実行し、それをテストしました。私はこの素敵な小さな例外を取得します。
System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Evidence evidence)
at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProc
さて、これはそれがdata.entityへの参照が必要と言われますので、私はまだ自分自身に考えています追加、これは奇妙ですが、これを行うために持っていなかったと私は私が作成したoncesを返していますエンティティオブジェクトを返さないのですが、私はそれをやりました。まだ同じエラー
私はそれが私がそれを選択するに関係なく、私はwebmethodをコメントし、helloworldを作ったと私は見た。
私は何人かの人々はあなたが私がやったのWebConfigとまだ同じエラーに
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
を追加suggestthatグーグルに見えました。私は毎日のようなこの種のことをやって、私はこれのようなエラーは一度もありません。そして、EF構造はforeignkeyを持つ特別な5つのテーブルではありません。
私はWS/CLプロジェクトを削除して再作成しました。
のplsは私が各POCOクラスで、基本的POCO項目にDB項目を変換し、この
namespace CL
{
public class Item
{
public static implicit operator Item(DB.Item db)
{
return new Item
{
Created = db.Created,
Id = db.ItemId
};
}
}
}
を持って
...問題を発見
ありがとうございました。私は、グローバルで事前修飾されたアイテムを変換するためのアイテムの名前空間を持っていて、同じエラーが発生した完全な名前空間を持っていました。型の移動はオプションではなかったので、メソッドに変換したところ、すべて正常に動作しました。 – NKCSS