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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:04:41+00:00 2026-06-06T13:04:41+00:00

I am creating a web application with MVC3 and MEF. I am attempting to

  • 0

I am creating a web application with MVC3 and MEF. I am attempting to export my HostModel to the plugin with an IDNumber and then have the plugin redirect to a link using that IDNumber. My model is not being exported correctly and then my view is also not reading the model from the plugin controller (I tested this by making a test model object and passing that to the view). I’m pretty sure I have some mix up with how I am exporting to the view in my plugin. I am using a .aspx file and not a .vbhtml because VS2010 didn’t give me the option. When I tried to drag a .vbhtml file into the project it didn’t work correctly.

Here is my HostController:

<Export(GetType(HostModel))>
<PartCreationPolicy(CreationPolicy.NonShared)>
Public Class HostController
    Inherits System.Web.Mvc.Controller


    Private m_objHost As HostModel

    Private m_IDNUmber As String
    Property IDNumber() As String
        Get
            Return m_IDNUmber
        End Get
        Set(value As String)
            m_IDNUmber = value
        End Set
    End Property


    Function Index() As ActionResult
        ViewData("Message") = "Welcome to ASP.NET MVC!"
        If m_objHost Is Nothing Then
            m_objHost = New HostModel
        End If
        Return View(m_objHost)
    End Function

    '<HttpPost()>
    Function ChangeCUNumber(model As HostModel, strIDNumber As String) As ActionResult
        ' m_IDNUmber = strIDNumber
        model.IDNumber = strIDNumber
        Return View("Index", model)
    End Function

    <HttpPost()>
    Function GoToMini(model As HostModel) As ActionResult
        m_CUNUmber = model.CUNumber
        Dim hostContollerObj As New HomeController
        hostContollerObj.CUNumber = model.IDNumber

        m_objHost = model
        Return Redirect("http://localhost:3727/miniView")
    End Function
End Class

This is my HostModel:

Public Class HostModel
Implements IHost

Private Shared m_instance As HostModel
Private m_IDNumber As String

Public Sub New()
End Sub



Shared ReadOnly Property instance() As HostModel
    Get
        If m_instance Is Nothing Then
            m_instance = New HostModel
        End If
        Return m_instance
    End Get
End Property


Public Property IDNumber As String Implements CUCMCV_Interfaces.IHost.IDNumber
    Get
        Return m_IDNumber
    End Get
    Set(value As String)
        m_IDNumber = value
    End Set
End Property

This is my plugin controller:

<Export(GetType(IPlugin))> _
<ExportMetadata("PluginName", "miniView")> _
<PartCreationPolicy(CreationPolicy.NonShared)> _
Public Class miniViewController
    Inherits System.Web.Mvc.Controller
    Implements IPlugin


    <Import(GetType(HostModel))>
    Private m_objHost As HostModel


    Public Function Index() As ActionResult
        Dim renderedView As ViewResult = View("~/Plugin/miniView.dll/miniView.Index.aspx", m_objHost)

        Return renderedView
    End Function

This is my plugin view (Index.aspx)

Public Class Index
    Inherits Mvc.ViewPage




    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        Dim p As ImportData = New ImportData()
        Dim strMINILink As String = "http://inside/mini?ContractNumber="
        Dim strCUNumber As String = p.instance.IDNumber
        Dim strMINIURL As String = strMINILink & strIDNumber
        Response.Redirect(strMINIURL)

    End Sub

End Class

Public Class ImportData

    <Import(GetType(HostModel))>
    Property instance As HostModel

    Public Sub New()
        Dim catalog As AggregateCatalog = New AggregateCatalog()

        catalog.Catalogs.Add(New DirectoryCatalog("C:\Documents and Settings\gbv0860\My Documents\cucmConsolidatedView\CUCMCV\cucmConsolidatedView\cucmConsolidatedView\bin"))
        Dim _container As CompositionContainer = New CompositionContainer(catalog)

        Try
            _container.ComposeParts(Me)

        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        End Try

    End Sub
End Class

Any help would be much appreciated! If you need me to clarify anything please let me know! 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-06-06T13:04:42+00:00Added an answer on June 6, 2026 at 1:04 pm

    You have put <Export(GetType(HostModel))> on the HostController class which isn’t actually a HostModel. That’s not a valid export.

    ASP.NET MVC will request controllers by their exact type, so you should export HostController with just <Export>.

    The <Export(GetType(HostModel))> probably belongs on the HostModel class. And instead of implementing your own singleton, you should just mark it with <PartCreationPolicy(CreationPolicy.Shared)>.

    Then there is the fact that you have an import on ImportData, but that class also isn’t exported and you just create it yourself with a new statement. Therefore MEF will never see these instances and won’t do anything with the imports.

    Finally, note that ASP.NET MVC will not automatically use MEF to create objects. You need to register a dependency resolver which wraps a MEF container to set that up. There appears to be a composition provider for APS.NET MVC in MEF2.

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

Sidebar

Related Questions

I am creating a new web application using ASP.NET MVC3 Razor and HTML 5.
I am currently creating an MVC3 application using Ninject. I have two controllers which
I am creating a web application using Netbeans and servlets. I have used some
I am creating a web application using EJBs and servlets. I have a page
I am creating a web application using backbone.js. I have two tabs. Tab 1
I have a question regarding using LightSpeed in a MVC3 Web application. I am
I am creating a web application using zend, here I create an interface from
I am creating a web application using HTML5 canvas to draw images ( like
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and

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.