关于c#:MetadataException [无法加载指定的元数据资源]

MetadataException [Unable to load the specified metadata resource]

我真的需要帮助。有很多关于stackoverflow错误的信息。但是他们都没有帮助。下面是问题描述,在这个问题的底部。

MetadataArtifactProcessing
- this is set to"embed in output assembly", which is correct

app.config
- I know the connectionstring have to be in the config file from the running
assembly. I've done this.

x86/x64 bit I've doublechecked the compilations and framework versions
and everything is as it should be
(which in this case means .net 4 and
x86).

Path to res://*/Something.ssdl This is, perhaps, the most error-prone
option. I've tried locate the dll path
manually but only got very spooky
errors. Assembly not found or invalid
codebase or version. If I leave it a
star, it will seach the available
assemblies. However there are reports
saying that 3-tier applications must
exactly match (with printed assembly version and so on). Though, the
how-description are very unclear and
does not work either.

Name of resource .NET Reflector are used and I found the resources
names in (csdl, ssdl, msl) in the data class assembly. That name is exactly
corresponding to the config file. I have also tooked in mind that the resources get
the name of the path and original filename (maph/maph/filename.edmx).

Name of the connectionstring The add name='' of the connectionstring
is exactly corresponding to the name
being searched for.

描述这是一个三层应用程序,其中edmx位于name.data.dll中。我使用内置的Visual Studio 2010实体Poco生成器创建了Poco。将POCO移动到业务层(是的,我修复了移动POCO时出现的路径错误)。

当我在第三层控制台测试应用程序中,尝试向POCO请求数据时,就会出现这个问题(如标题中的wroted)。我真的希望你明白这不是一个"只是复制品",我真的需要对话来解决这个问题。

谢谢你的好意,

更新:因为这似乎与一个错误的逻辑相对应,我认为我搜索的答案更多的是"我将如何在表示-业务-数据"分层系统中使用EF"类型。


我认为app.config文件中的连接字符串不正确。您可以尝试以下操作:

1
Data Source=(IP address of DB);Initial Catalog=(DB name);Integrated Security=True;MultipleActiveResultSets=True

不确定这是否与您当前的异常直接相关,但显然您的项目结构存在一些问题。

如果要将EF4与POCO T4模板一起使用,必须关闭实体设计器中的默认生成器。POCO模板可以放置在单独的项目中,但项目定义实体模型(以及可能派生的ObjectContext)必须引用此程序集。

请遵循以下教程了解如何使用POCO:

  • 第1部分
  • 第2部分