0

I have a program that is primarily an addin to another program. I have my core logic, UI, etc. in a single project which can also be used independently of the parent program. Then I have a 'connector' piece that connects my program to the parent program and is essentially a communicator between the two. I also support multiple versions of the parent software.

Now here is the issue. I have my core program that uses System.Windows.Interactivity.dll. It seems the parent program also uses this, but earlier supported versions of the parent use the .NET 4.0 version of interactivity and later supported versions use .NET 4.5 version.

My core software works if I compile with the 4.0 version or the 4.5 version, but when it's running inside the parent, if I have the 4.5 version it breaks in earlier versions and if I have 4.0 installed it breaks in later versions...

Is there a way I can create two different builds that compile on the different dll files? I guess I'm going to need to have two different install locations based on which one I want?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
sfaust
  • 2,089
  • 28
  • 54
  • .NET Framework 4 is end of life, so you do have a good reason to stop supporting it, https://support.microsoft.com/en-ca/help/17455/lifecycle-faq-net-framework – Lex Li Jul 29 '18 at 01:56
  • Noted, however They are the parent company and I add in to theirs. I have to support older versions because many of my customers have projects still on older versions of the parent software (technical reasons it's not always a good idea to upgrade). Anyway the parent supports up to 3 years back so I have to as well, which includes some .NET 4.0 libraries. – sfaust Jul 29 '18 at 05:43

1 Answers1

2

This will do what you want:

1) Add new configurations for each (where you normally pick between Debug and Release).

enter image description here

In my example I'll go with TheNet40one and TheNet45One.

2) Edit your project's .csproj file and add the following (I'll just demo AnyCPU):

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'TheNet40One|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\TheNet40One\</OutputPath>
    ...
</PropertyGroup>

3) Then add conditional references (obviously I am guessing at your .dll names):

<ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    ...
    <Reference Include="40.dll" Condition="'$(Configuration)'=='TheNet40One'" />
    <Reference Include="45.dll" Condition="'$(Configuration)'=='TheNet45One'" />
</ItemGroup>

I've used ... to replace other common settings and references - don't forget to replace them.

Now you can switch between the two build configurations, knowing they will each link in the correct DLL file.

enter image description here

Ben Hall
  • 1,353
  • 10
  • 19
  • Awesome, I was hoping there was something like that... Let me try it and I'll hopefully be back to mark as an answer :) – sfaust Jul 27 '18 at 18:21
  • How did you get on @sfaust? – Ben Hall Jul 27 '18 at 19:43
  • Sorry, got pulled away on something else for a bit and just got back to this. Need to figure out what that's going to do to my install system but this seems to work, thank you! – sfaust Jul 28 '18 at 05:43
  • 1
    Just wanted to report back that it took a bit of figuring out to support what I want but it worked, so thank you! – sfaust Jul 29 '18 at 05:44