Reputation: 4697
Suppose I have a class library with some conditional compilation, that eventually gets built to MyPortable.dll and MyPortable.X.dll, where the latter is the version compiled with the conditional enabled.
Then I have my "Core" project which references "MyPortable.dll". So far so good.
However, my problem lies in the third project (the "App"), which has a reference to "Core", but needs to use "MyPortable.X.dll" (which is a different build that "Core" uses), but because "Core" is linked against to "MyPortable.dll", my "App" ends using that same version as well, instead of "MyPortable.X.dll".
Is there any way to do that? The code is something like this:
MyPortable
namespace MyPortable
{
public class Person {
public string Name { get; set; }
}
public class Something {
public List<Person> GetPersons() {
List<Person> l = new List<Person>();
l.Add(new Person { Name = "Name 1" });
#if PLATFORM_X
l.Add(new Person { Name = "Name 2" });
#endif
return l;
}
}
}
I first compile MyPortable without "PLATFORM_X" enabled, and then I compile again, this time with the flag turned ON. File references are below (note that I am referencing Core.csproj directly):
Core\References\MyPortable.dll
App\
\References\Core.csproj
\References\MyPortable.X.dll
Upvotes: 0
Views: 4547
Reputation: 253
You can control assembly binding from the config file, although I'm not sure that this is exactly what you are looking for.
Essentially you can tell your application to bind to a specific assembly:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="myAssembly"
publicKeyToken="32ab4ba45e0a69a1"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I took the above example from the MSDN documentation located here:
http://msdn.microsoft.com/en-us/library/2fc472t2.aspx
Hope that helps,
Chris
Upvotes: 0
Reputation: 65516
If I understand you correctly then yes. You edit your project file to include conditional MSBUILD statements for the references/run times you need in which ever version.
I had a simillar answer here : Visual Studio loading the right (x86 or x64) dll!
Thought that in particular used the Build Platform/Target as the variable. I assume that you're using different Targets for setting the compilation conditions?
Upvotes: 1