Am I the only one getting “Assembly Not Available

2020-05-07 18:24发布

I have had a persistent problem with Visual Studio 2010 and any framework version reporting this error, after adding a test project:

"Assembly Not Available in the Currently Targeted Framework"

So far, I have had this happen with only two assemblies, and always consistently:

  • System.ServiceProcess
  • System.Configuration.Install

The problem is that the project file does not identify a specific framework version for these references, showing version 0.0.0.0 in the properties. I can work around this by manually altering the project file to include <SpecificVersion>True</SpecificVersion> in the reference element.

This is a problem, because I am unable to Mole types that inherit or implement these problematic assemblies. The issue is that Pex and Moles generate their own project files, which are also broken, during the build process. There is no opportunity to manually fix these, and I think it's just stupid to have to build a workaround using ICorProfilerCallback.JITCompilationFinished to get anything to compile.

So, does anyone else have this issue? I have already re-installed VS2010. I don't see any fix for this.

I have most certainly researched this, and have been working around it all year. I'm getting rather annoyed by this, and think something has simply gone wrong or I don't understand that this is intended behavior (I can't imagine why...).

3条回答
欢心
2楼-- · 2020-05-07 18:49

Visual Studio 2010 generated the following reference elements, in the .csproj files:

<Reference Include="System.Configuration.Install" />
<Reference Include="System.ServiceProcess" />

To correct the problem, the XML must be modified, to:

<Reference Include="System.Configuration.Install">
    <SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="System.ServiceProcess">
    <SpecificVersion>True</SpecificVersion>
</Reference>
查看更多
女痞
3楼-- · 2020-05-07 19:02

Go into project properties and change the Target Framework to .NET Framework 4. I'm guessing you're using a project type whose default is .NET Framework 4 Client Profile. (like console app, for example)

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2020-05-07 19:09

I'm having exactly the same problem with Visual Studio suddenly being unable to reference these assemblies: System.ServiceProcess System.Configuration.Install

The only way to fix it is to re-install Visual Studio 2010 and abandon all hope of using Moles until it's fixed.

查看更多
登录 后发表回答