Lost_DM
Lost_DM

Reputation: 951

Assemblies with the same name referenced ignoring hint path

My code relies on a third party library (dll).

Due to Nugget's inability to manage different platforms (also here), I've created two projects with the same code duplicated (kept code to a minimum - basically an API wrapper).

One project references the x86 version of the dll, and the other x64.

There is only one project in my solution that references these projects.
It references them both, and does so conditionally (so when I build with x64 configuration the project referencing the x64 dllis referenced, etc)

Its .csproj contains something like:

ProjectReference Include="..\3rdPartyModule.x86\3rdPartyModule.x86.csproj" Condition="'$(Platform)' == 'x86'"

and

ProjectReference Include="..\3rdPartyModule.x64\3rdPartyModule.x64.csproj" Condition="'$(Platform)' == 'x64'"

Now, a strange thing happens:

If I unload both projects and then load first the x86 one and then the x64 one, the reference in the x64 one actually shows that it points to the x86 dll (I can see the path).

If I change the order of load, then it's the other way around: the x64 is fine, but the x86 is references the x64 version!

My guess is that VS finds an assemby with te same name already in memory and automatically references the second to the first.

Is this a known issue? Is there a way around it?

Upvotes: 2

Views: 432

Answers (1)

Jarek Kardas
Jarek Kardas

Reputation: 8455

There used to be a bug in VS2010 where in such cases references were not displayed properly in VS UI, but correct file would be copied over during compilation. In your case, are you getting correct version of the file in build output directory?

Also, you may want to set different alias for the referenced assembly (from reference properties). It might help.

Upvotes: 1

Related Questions