Hi All,
Thanks to LE on this forum and MSDN there is a resolution to this.
You have to mark the reference as SpecificVersion = true
Below are the steps that were recommended to me on the MSDN forums.
Start Quote
Step1: Unload the referencing project targeting .NET 2.0
Step2: Right click the unloaded project and select edit from
context menu
Step3: Add
true to the
reference. Below is a sample from my repro solution:
{8DD71CAF-BEF7-40ED-9DD0-25033CD8009D}
HighFX
true
Step4: Reload the project.
Now your should be able to build within the Visual Studio 2010, there
could still be a warning as below, but the build can be successful.
Warning 1 The project 'XXX' cannot be referenced. The referenced project is
targeted to a higher framework version (3.5)
End Quote.
Note there are a couple of issues I came across with this technique and so
those who are interested please see the full MSDN post at
http://social.msdn.microsoft.com/Forums/en-GB/msbuild/thread/dfadfb34-5328-4c53-8274-931c6ae00836
Regards,
Adam
"Adam Davis"
wrote in message
news:6372671@discussion.autodesk.com...
> Hi All,
>
> As an AutoCAD 3rd party developer we create .NET dlls to target multiple
> versions of AutoCAD. In Visual Studio 2010 our preferred way of finessing
> this no longer works.
>
> I have put a question up on MSDN that outlines the problem. If I hear back
> with any resolution to this I will post here. In the meantime if anyone
> has
> anything to add then feel free...
>
> Start of MSDN Post
> Hi,
>
> Hope this is the correct forum.
>
> We develop applications on AutoCAD. Each version of AutoCAD use a
> different
> .NET Framework version dependent on the release dates current Framework
> version. As the application dll is loaded into AutoCAD it must be compiled
> on the same Framework version or lower as that AutoCAD requires.
>
> Newer versions of AutoCAD have new functionality that we can conditionally
> use via reflection to check AutoCAD version. In order to use the AutoCAD
> API
> we simply reference 2 dlls (names do not change per version)
>
> In VS 2008 we could compile a dll targeted at 2.0 (so it would load on any
> AutoCAD) that referenced the latest AutoCAD API dll that are targeted at
> 3.5. ie myapp.dll(2.0) referenced acdbmgd.dll(3.0). A warning would be
> given
> but it would build in the VS IDE.
>
> In VS 2010 this is not allowed. When building in the VS IDE it fails with
> warning.
> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9):
> warning MSB3268: The primary reference "acdbmgd, Version=18.0.0.0,
> Culture=neutral, processorArchitecture=MSIL" could not be resolved because
> it has an indirect dependency on the framework assembly
> "PresentationFramework, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35" which could not be resolved in the
> currently targeted framework. ".NETFramework,Version=v2.0". To resolve
> this
> problem, either remove the reference "acdbmgd, Version=18.0.0.0,
> Culture=neutral, processorArchitecture=MSIL" or retarget your application
> to
> a framework version which contains "PresentationFramework,
> Version=3.0.0.0,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" and errors that all the
> functions/types used in the api dll are not defined.
>
> Strangely, also I can add the reference (albeit with the same warning
> about
> framework versions as VS 2008) and there will be no problem with the
> intellisense so it can read the API dll - it just fails at build.
>
> I can build the whole thing targeted at 2.0 (if I remove the newer
> functionality) and then load it into a newer AutoCAD so this proves at
> runtime that a 2.0 can access a 3.0 dll - it's just VS 2010 being picky at
> build time.
>
> Now I know that VS is just trying to help :-). It's trying to make sure it
> doesn't crash at runtime as the newer framework may not be available. I,
> however, know what I am doing (debatable) so is there a way that I can
> turn
> off this particular check.
>
> End of MSDN post.
>
> Regards to all,
>
> Adam
> Adam Davis
> Wish Software Limited
> http://www.wishsoftware.com