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

  • Home
  • SEARCH
  • 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 6612853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:08:51+00:00 2026-05-25T20:08:51+00:00

Since version 3.0, .NET installs a bunch of different ‘reference assemblies’ under C:\Program Files\Reference

  • 0

Since version 3.0, .NET installs a bunch of different ‘reference assemblies’ under C:\Program Files\Reference Assemblies\Microsoft…., to support different profiles (say .NET 3.5 client profile, Silverlight profile). Each of these is a proper .NET assembly that contains only metadata – no IL code – and each assembly is marked with the ReferenceAssemblyAttribute. The metadata is restricted to those types and member available under the applicable profile – that’s how intellisense shows a restricted set of types and members. The reference assemblies are not used at runtime.

I learnt a bit about it from this blog post.

I’d like to create and use such a reference assembly for my library.

  1. How do I create a metadata-only assembly – is there some compiler flag or ildasm post-processor?
  2. Are there attributes that control which types are exported to different ‘profiles’?
  3. How does the reference assembly resolution at runtime – if I had the reference assembly present in my application directory instead of the ‘real’ assembly, and not in the GAC at all, would probing continue and my AssemblyResolve event fire so that I can supply the actual assembly at runtime?

Any ideas or pointers to where I could learn more about this would be greatly appreciated.

Update: Looking around a bit, I see the .NET 3.0 ‘reference assemblies’ do seem to have some code, and the Reference Assembly attribute was only added in .NET 4.0. So the behaviour might have changed a bit with the new runtime.

Why? For my Excel-DNA ( http://exceldna.codeplex.com ) add-in library, I create single-file .xll add-in by packing the referenced assemblies into the .xll file as resources. The packed assemblies include the user’s add-in code, as well as the Excel-DNA managed library (which might be referenced by the user’s assembly).

It sounds rather complicated, but works wonderfully well most of the time – the add-in is a single small file, so no installation of distribution issues. I run into (not unexpected) problems because of different versions – if there is an old version of the Excel-DNA managed library as a file, the runtime will load that instead of the packed one (I never get a chance to interfere with the loading).

I hope to make a reference assembly for my Excel-DNA managed part that users can point to when compiling their add-ins. But if they mistakenly have a version of this assembly at runtime, the runtime should fail to load it, and give me a chance to load the real assembly from resources.

  • 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-25T20:08:52+00:00Added an answer on May 25, 2026 at 8:08 pm

    To create a reference assembly, you would add this line to your AssemblyInfo.cs file:

    [assembly: ReferenceAssembly]
    

    To load others, you can reference them as usual from your VisualStudio project references, or dynamically at runtime using:

    Assembly.ReflectionOnlyLoad()

    or

    Assembly.ReflectionOnlyLoadFrom()


    If you have added a reference to a metadata/reference assembly using VisualStudio, then intellisense and building your project will work just fine, however if you try to execute your application against one, you will get an error:

    System.BadImageFormatException: Cannot load a reference assembly for execution.

    So the expectation is that at runtime you would substitute in a real assembly that has the same metadata signature.

    If you have loaded an assembly dynamically with Assembly.ReflectionOnlyLoad() then you can only do all the reflection operations against it (read the types, methods, properties, attributes, etc, but can not dynamically invoke any of them).


    I am curious as to what your use case is for creating a metadata-only assembly. I’ve never had to do that before, and would love to know if you have found some interesting use for them…

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

Sidebar

Related Questions

The .NET Framework contains since version 3.0 the ObservableCollection<T> , but why isn´t there
PowerBuilder seems to have some support for plug-ins since version 10. However, I can't
Since the latest version of NSS does not provide the SSLSample program, I copied
My latest released program is version 2.0.1.0, but since it's just in beta I
Since version 1.5 Subversion supports to have a local caching-proxy for the main Master-repository.
Being a C# developer since version 1.0, F# has captured my free time for
I've been developing modules for DNN since version 2 and back then I was
Good news! Since version 4.8 BerkeleyDB has c# interface. BerkeleyDB is a quite interesting
Since in log4j javadoc is WARNING: This version of JDBCAppender is very likely to
At my workplace we are using CVS as the version control system. Since we

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.