Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:33:55+00:00 2026-05-22T21:33:55+00:00

Is it possible to reference an assembly from a shared location or the GAC

  • 0

Is it possible to reference an assembly from a shared location or the GAC with Unity?

Assume I have two projects (under the same solution):

  • MyProject.Data (Repository interfaces)
  • MyProject.Data.EntityFramework (Repository Entity Framework Implementation)

I want to use IoC in an ASP.NET MVC application (MyProject.Web) which is also under the same solution, but I don’t want to add project references for both the interfaces AND the implementation. Ideally, I want to add a project reference to the interfaces, and load the implementation from a shared location or the GAC. This prevents any of the code in MyProject.Web creating instances of a specific implementation – this should always be done by the IoC provider.

I could decide to create an nHibernate implementation and IoC would make the switch a lot easier. If there was any direct coupling, it’d be a nightmare. And this leads me back to the question. Lets remove the possibility for developers to instantiate concrete implementations without asking the IoC container how to resolve an interface.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:33:55+00:00Added an answer on May 22, 2026 at 9:33 pm

    Unity can only instantiate types it can get hold of, so your MyProject.Data.EntityFramework assembly has to be in your MVC output directory if you want to use its types. If you don’t want to directly reference the project you could copy the assembly in using a build action, but going down that route means you have to configure Unity using XML instead of the API, which can be a bit of a pain and loses you the advantages of type-checking you get with the API.

    Ultimately I’d go with using the API and directly referencing the project. This should be accompanied by education so other developers know how the system architecture is supposed to be used, as well as code reviews to help enforce it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to reference a .NET Assembly from a SQL Server Stored procedure
Is it possible to reference a .NET assembly from ColdFusion? If so, how can
Is it possible to hold a reference to an Assembly from another appdomain without
We want to have two .NET apps running on the same machine communicate with
I have assembly A that depends (statically) on type T (reference type, a class)
Possible Duplicate: Reference: Comparing PHP's print and echo Is there any major and fundamental
Is it possible to reference an outer query in a subquery with MySQL? I
Possible Duplicate: Returning reference to a local variable I happened to find this code
Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I
Possible Duplicate: Difference between pointer variable and reference variable in C++ I am reading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.