Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting Castle reference #86

Closed
gregsaab opened this issue Sep 4, 2012 · 4 comments
Closed

Conflicting Castle reference #86

gregsaab opened this issue Sep 4, 2012 · 4 comments

Comments

@gregsaab
Copy link

gregsaab commented Sep 4, 2012

It would be great if the nuget package depended on Castle.Core and the aforementioned library was not merged into NSub's dll. This issue was referenced at: http://stackoverflow.com/questions/12266279/how-to-fix-type-exists-in-both-assemblies-failure-when-using-dynamicproxy-type

@dtchepak
Copy link
Member

dtchepak commented Sep 4, 2012

I'm happy for someone to setup a non-merged version in the build. I'd like to keep the ilmerged package as well though, as both approaches have their own drawbacks (example).

To work around the current issue you could try using a namespace alias.

@jrnail23
Copy link

@dtchepak, I just hit this same problem myself, interestingly I was doing the exact same thing @gregnehus was trying to do in his SO question.
Unfortunately namespace alias doesn't help this scenario.
The problem is that the if you have both Castle.Core and NSubstiture referenced in the same project, then you have two separately defined types with completely identical type names, including the full namespace. The compiler can't figure out which Castle.DynamicProxy.IProxyTargetAccessor we're trying to use.

Perhaps there's a way to make NSubstitute's usage of IProxyTargetAccessor internal, such that the type doesn't have to be visible to consuming projects? I see that you're explicitly listing it in your ilmerge.exclude file, although never having done any IL merging myself, I have no idea what the implications are either way.

@jrnail23
Copy link

Per this blog post (http://www.davidarno.org/c-howtos/aliases-overcoming-name-conflicts-part-2-extern-alias/), apparently the work around is to use extern alias
I did it and it worked.

@dtchepak
Copy link
Member

dtchepak commented Oct 7, 2017

Closing as NSubstitute 3.0 no longer ilmerges dependencies. 2.x works with extern alias.

@dtchepak dtchepak closed this as completed Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants