我已将运行 3.5 vs2008 的 WCF 项目升级到 .net 4.0 vs2010,但遇到了问题。当从 vs2010 编译时,我的服务实现项目中的程序集被 devenv.exe 锁定(注意没有调试 - 仅编译)。该程序集在vs2010重启时释放,每次重启后都可以编译一次。到目前为止我已经尝试过的操作:
- 插入 PreBuild 事件来解锁程序集
- 删除程序集版本通配符
- 禁用源步进
- 停止 Windows 搜索
- 停止 IIS
- 退出 vs2010,删除 sln.suo 和 bin/obj 文件夹
- 现在阅读博客和 SO 帖子 3 天: )
- 从服务项目中删除了所有引用并阅读了它们,
我几乎没有想法了,而且微软似乎没有对此进行解释,无法修复。任何想法将不胜感激!
错误信息:
无法复制文件“.....某些
路径...\Debug\HelperLibrary.Service.dll”到
“bin\Debug\HelperLibrary.Service.dll”。该进程无法访问
文件“bin\Debug\HelperLibrary.Service.dll”,因为它正在被使用
另一个进程。
奖金信息:
使用 msbuild 从提示符进行编译时,没有问题。仅当从 vs2010 编译时。旧的vs2008解决方案当然仍然有效。
Microsoft 票证: https://connect.microsoft.com/VisualStudio/feedback/details/682485/use-of-testaccessor-and-impl-of-codeaccesssecurityattribute-locks- assembly
I've upgraded a WCF project running 3.5 vs2008 to .net 4.0 vs2010 and run into a problem. When compiling from vs2010 an assembly in my service implementation project is locked by devenv.exe (note no debugging - only compiling). The assembly is released when vs2010 is restarted and can be compiled once, after each restart. What I've tried to far:
- Insert PreBuild event to unlock the assembly
- removed assembly version wild card
- Disabled source stepping
- stopped windows search
- stopped IIS
- quit vs2010, removed sln.suo and bin/obj folder
- Read blog and SO posts for 3 days now :)
- Removed all references from the service project and readded them
I've pretty much run out of ideas and it seems that Microsoft have no explaination for this an no fix. Any ideas would be greatly appreciated!
Error Message:
Unable to copy file ".....some
path...\Debug\HelperLibrary.Service.dll" to
"bin\Debug\HelperLibrary.Service.dll". The process cannot access the
file 'bin\Debug\HelperLibrary.Service.dll' because it is being used by
another process.
Bonus information:
When compiling from prompt with msbuild, there's no problem. Only when compiling from vs2010. The old vs2008 solution of course still work.
Microsoft Ticket: https://connect.microsoft.com/VisualStudio/feedback/details/682485/use-of-testaccessor-and-impl-of-codeaccesssecurityattribute-locks-assembly
发布评论
评论(2)
这是一个不太可能的情况,但是您的 web.config 是否有可能有 'shadowCopyBinAssemblies' 设置为“false”?或者上游配置文件已关闭该设置?
我认为这可能会导致您所看到的问题。
This is a long shot, but is there any chance that your web.config has 'shadowCopyBinAssemblies' set to 'false'? Or that an upstream config file has that setting turned off?
I think that might cause the problem you're seeing.
好的,我的同事度假回来后说他早些时候遇到了这个问题:)
程序集被锁定(或由构建过程持有)的根本原因似乎是由于使用 testaccessors 结合 CodeAccessSecurityAttribute 的实现来测试私有方法。请注意,这在 Visual studio 2008 中不是问题,而仅在 2010 中出现
请参阅此处的另一个案例:
http://social.microsoft.com/Forums/en/Offtopic/thread/41ceebce-1ecf-4962-86d0-e68050df4a99
除了改变之外,我还没有找到解决方案将私有方法改为公共方法 - 我将针对此问题创建一个新帖子。
Ok, so my colleague gets back from vacation and said he bumped into this problem earlier :)
It seems that root cause for the assembly to be locked (or held by the building process), is due to the use of testaccessors to test private methods, in combination of an implementation of CodeAccessSecurityAttribute. Note that this is not a problem in Visual studio 2008, but only in 2010
See another case here:
http://social.microsoft.com/Forums/en/Offtopic/thread/41ceebce-1ecf-4962-86d0-e68050df4a99
I've yet to find a solution for this, besides altering the private methods to public - I'll create a new post for this problem.