“构建”时的问题引用另一个项目的 WCF REST 服务

发布于 2024-11-26 18:53:28 字数 1063 浏览 1 评论 0原文

我有一个包含两个项目的解决方案:

  1. DataAccessLayer 项目 - 一个不言自明的类库,它引用 .NET MySql 连接器 dll,并能够将其设置保存到设置文件 .
  2. WebService 项目 - 具有 WCF REST 服务,该服务具有对 DataAccessLayer 项目的引用。

构建“WebService”项目(在“发布”模式下)后,我无法在“WebService”发布文件夹中找到 DataAccessLayer.dll.config 文件和 MySql.Data.dll 文件。

更新: 好吧,经过一些实验,我发现在“DataAccessLayer”项目中将“MySql.Data.dll”引用的“Copy Local”属性设置为 true,将其复制到构建时的 DataAccessLayer“发布文件夹”。但是,在构建“WebService”项目时,我在“WebService”的 bin\Release 文件夹中看到的唯一文件是“DataAccessLayer.dll”文件、“WebService.dll”文件及其相对的“.pdb”文件。 (仍然没有 MySql.Data.dll 和 DataAccessLayer.dll.config)。

更新2: 好吧,不确定是否有更优雅或更好的解决方案,但我最终向“WebService”项目添加了“Post-Build”事件(项目属性 -> Build Events),该项目从“DataAccessLayer”输出复制两个文件目录到“WebService”输出目录,按以下方式:

copy "$(SolutionDir)DataAccessLayer\bin\$(ConfigurationName)\MySql.Data.dll" "$(TargetDir)" &
copy "$(SolutionDir)DataAccessLayer\bin\$(ConfigurationName)\DataAccessLayer.dll.config" "$(TargetDir)"

如果有人想到更通用的方法来执行此操作,请告诉我!

谢谢,

麦基

I have a solution with two projects:

  1. DataAccessLayer project - A self explanatory class library, which has a reference to .NET MySql connector dlls and able to save it's settings to a Settings file, .
  2. WebService project - has the WCF REST service which has a reference to the DataAccessLayer project.

After I build the "WebService" project (in 'Release' mode) I cannot locate both the DataAccessLayer.dll.config file and MySql.Data.dll file in the "WebService" Release folder.

UPDATE:
Well, after some experimenting I figured that setting "MySql.Data.dll" reference's "Copy Local" property to true in the "DataAccessLayer" project, copies it to the DataAccessLayer "Release Folder" on build. But still, when building the "WebService" project - the only files I see in the "WebService"'s bin\Release folder are the "DataAccessLayer.dll" file, the "WebService.dll" file and their relative ".pdb" files. (still no MySql.Data.dll and DataAccessLayer.dll.config).

UPDATE 2:
Ok, not sure there's a more elegant or better solution but I ended up adding a "Post-Build" event (Project Properties -> Build Events) to the "WebService" project, which copies the two files from the "DataAccessLayer" output directory to the "WebService" output directory, in the following manner:

copy "$(SolutionDir)DataAccessLayer\bin\$(ConfigurationName)\MySql.Data.dll" "$(TargetDir)" &
copy "$(SolutionDir)DataAccessLayer\bin\$(ConfigurationName)\DataAccessLayer.dll.config" "$(TargetDir)"

If anyone thinks of a more generic way of doing this, please let me know!

Thanks,

Mikey

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音栖息无 2024-12-03 18:53:28

我假设 MySQL.Data.dll 被 DataAccessLayer 项目引用。如果是这种情况,请转到参考并打开其属性。应该有一个选项显示“复制本地”,仔细检查它是否设置为 true(我认为它默认为 false)。如果这不是问题,您也可以尝试引用 WebService 项目中的 dll,这应该将其复制过来。或者您可以将 DLL 添加到 GAC,或者最坏的情况是,您始终可以手动复制文件(只要它位于 bin 目录中,它就应该找到它),但从长远来看,这会很糟糕。

I'm assuming that the MySQL.Data.dll is referenced by the DataAccessLayer project. If that's the case, go to the reference and open up its properties. There should be an option that says Copy Local, double check that it's set to true (I think it defaults to false). And if that isn't the issue, you can try referencing the dll in the WebService project also, which should copy it over. Or you could add the DLL to the GAC or, worst case scenario, you can always just copy the files over manually (as long as it's in the bin directory, it should find it), but that would suck long term.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文