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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:20:08+00:00 2026-05-11T15:20:08+00:00

I have the following scenario, with exception being thrown when I try to cast:

  • 0

I have the following scenario, with exception being thrown when I try to cast:

  1. I added a project reference and imported the project’s namespace.
  2. The LoadFile line loads the dll that is generated when this project is built.
  3. I am trying to access the public field of an attribute that decorates a property of an object from the dll.
  4. Here is the exception text:

[A]MyNamespace.PropertyMetaDataAttribute cannot be cast to [B]MyNamespace.PropertyMetaDataAttribute. Type A originates from ‘A, Version=12.0.0.25, Culture=neutral, PublicKeyToken=null’ in the context ‘LoadFrom’ at location ‘C:\projectA\bin\debug\A.dll’. Type B originates from ‘A, Version=12.0.0.25, Culture=neutral, PublicKeyToken=null’ in the context ‘Default’ at location ‘C:\currentProject\bin\debug\A.dll’.

code snippet:

using MyNamespace; // added project reference to this item  m_Assembly = Assembly.LoadFile(ConfigurationManager.AppSettings['DLL_File_Path']);   Type objectType = m_Assembly.GetType(string.Format('{0}.{1}', NAMESPACE_PREFIX, 'MyObject'));   // Crash happens on line below:   Attribute attr = (Attribute) objectType.GetProperty('Name').GetCustomAttributes(false)[0];  //This is the layout of the object which has the property  MyObject  {     [MyAttribute(Name='FooName')]     Foo {get;set;}  }  // This is the definition of the attribute  MyAttribute :Attribute  {     // Want to access the value     public string Name = string.Empty;  } 
  • 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. 2026-05-11T15:20:08+00:00Added an answer on May 11, 2026 at 3:20 pm

    It seems like your

    ConfigurationManager.AppSettings['DLL_File_Path'] 

    Is pointing to the same dll in other location, so the .Net runtime tries to load a dll already loaded, when you try to use it, the Type System blows up because of the types being repeated between the 2 dll’s…

    According to the error, these are the locations of the two dll’s

    • C:\currentProject\bin\debug\A.dll
    • C:\projectA\bin\debug\A.dll

    If the reference is explicitly set on the solution, you can try to set copy local to False so when the solution generates, don’t be copying the result of the dependencies

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

Sidebar

Related Questions

I got the above mentioned exception when performing following scenario. Students and Address have
I have the following situation where an Exception thrown in a ViewModel does not
I am trying to understand isolation/locks in SQL Server. I have following scenario in
I have the following scenario: in activity A, when a user clicks a button,
I have the following scenario: if(xml.Descendants(ns + Children).FirstOrDefault() != null) { XElement children =
I have the following scenario, a Customer who can have bank accounts in several
I have the following scenario :- template <typename T> class Base { public: virtual
I have the following scenario: Entities are loaded from the database. One of them
I have the following scenario where I want to pass in string and a
I have the following scenario. I have created an ASP.NET web application (framework 3.5)

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.