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 457613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:35:19+00:00 2026-05-12T22:35:19+00:00

I’ve created a factory assembly that can process any type of transaction (that supports

  • 0

I’ve created a factory assembly that can process any type of transaction (that supports ITransactionType). I can add more transaction types in separate assemblies, all of which will work with the factory without it needing to be recompiled (which is one of the benefits of a factory).

There is an actual list of transaction types that can be handled, so I’ve defined a static class with const strings, which is kept in a separate assembly. This is referenced by other assemblies to ensure consistent transaction type names. This assembly is not referenced by the factory, as it doesn’t need to know, and it would result in unnecessary compilations of that project.

All this works just fine. I’ll never reference the master list assembly in the factory project, because it know it doesn’t make sense.

However, I’m concerned that if the project is being maintained by someone who doesn’t understand all this, they may mistakenly add the reference to the master list assembly. Is there some way to prevent this reference from being added? IOW, if someone (perhaps even myself in the future) adds the reference, is there some way for me to force a compile error pointing to an explanation of why the behavior is unacceptable?

  • 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-12T22:35:19+00:00Added an answer on May 12, 2026 at 10:35 pm

    I can think of a few ways, though the language (.net, C#, vb) does not provide a specific method as far as I know:

    1. Use source control (you should, anyway), after compilation, unload the project from your solution (rightclick > unload), check in and mark as final, readonly or whatever to prevent further change.
    2. Add a little mini-script that does a pre-compilation step which checks for disallowed references (you can add it under project properties).
    3. Add a #warning to your source which is always issued: “should not be compiled with XXX”, please make sure it’s not in”.
    4. Use circular dependency against itself: add a reference to Transaction factory in your constants library, this will effectively prevent adding a reference the other way around.
    5. A bit nastier: dynamically check for the existence of the reference from the cctor (the static constructor) using reflection and throw an exception if found. This will throw a hard exception (but only on any test) if anybody ever attempts to add a reference to this lib.
    6. Perhaps more basic: in your nUnit tests (or whatever test framework you use), simply add one test: MustNotReferenceXXX and in its body, dynamically check whether the lib is referenced.

    I’ll update if I can think of anything easier, though I think points 5 and 6 are easiest to implement and future proof.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this

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.