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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:05:37+00:00 2026-05-24T11:05:37+00:00

Within my class I have a class that imports a type like this: [Import]

  • 0

Within my class I have a class that imports a type like this:

[Import]
public ContactViewModel ContactViewModel { get; set; }

The type is defined like this:

[PartCreationPolicy(CreationPolicy.NonShared)]
[Export(typeof(ContactViewModel))]
public class ContactViewModel {}

I am expecting whenever I would read from the property, to get a new instance right?
Or maybe not…I keep getting the same instance, how do I force t to make me a new instance when using the property?

Many Thanks,

  • 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-24T11:05:37+00:00Added an answer on May 24, 2026 at 11:05 am

    Are you sure you are recomposing your consumer class? The NonShared creation policy will ensure that a new instance is created each time the part is required to compose, so I would check the other side of it, which is the class where you are [Import]-ing your part. Is that class being recomposed correctly?

    Your other option is to use an ExportFactory, e.g.:

    [Import] public ExportFactory<ContactViewModel> ViewModelFactory { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a generic class that takes a type T . Within this class
I have subclassed a UITableViewCell and within this class I want to get it's
I have recently discovered that when I have pointers within a class, I need
Say I have a class which represents a person, a variable within that class
I have a property within a class, that I need to iterate through all
Say I have a method, and within that method it instantiates a Person class:
I have a class with many embedded assets. Within the class, I would like
If I have a class called myclass does having static methods within the class
I have been trying to return a collection from a property within a class
I have a menu within a page, I have an active class applied to

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.