Problem loading an assembly


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Problem loading an assembly

  1. #1
    Join Date
    Mar 2006
    Posts
    15

    Question Problem loading an assembly

    I've structured my application architecture similarly to the UIPAB quickstart samples so that I've got a presentation layer, business layer, data access layer etc. and my Controller is contained in a separate library called "MAJ.MyApplication.Common.dll".

    The problem occurs when it tries loading this assembly to get a reference to my Controller defined in the config file defined as follows:

    ...
    <views>
    <view
    name="StartView"
    type="MAJ.MyApp.WinUIPresentationLayer.StartView,
    MAJ.MyApp.WinUIPresentationLayer,
    Version=1.0.0.0,
    Culture=neutral,
    PublicKeyToken=null"
    controller="MyController"
    stayOpen="true"
    floatable="true" />

    </views>
    ...

    <controller
    name="MyController"
    type="MAJ.MyApp.Common.MyController,
    MAJ.MyApp.Common,
    Version=1.0.0.0,
    Culture=neutral,
    PublicKeyToken=null" />
    ...


    The exception is thrown in line 73 in GenericFactory.cs of the UIPAB:

    try
    {
    // Use full assembly name to get assembly instance
    assemblyInstance = Assembly.Load( typeSettings.Assembly );
    }
    catch(Exception e)
    {
    throw new UIPException( Resource.ResourceManager.FormatMessage( Resource.Exceptions.RES_ExceptionCantLoadAssembly, typeSettings.Assembly )+UIPException.GetFirstExceptionMessage(e), e );
    }


    with the following message and stack trace:

    Message: "Could not load file or assembly 'MAJ.MyApplication.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."

    StackTrace: " at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)\r\n at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)\r\n at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)\r\n at System.Reflection.Assembly.Load(String assemblyString)\r\n at Microsoft.ApplicationBlocks.UIProcess.GenericFactory.Create(ObjectTypeSettings typeSettings, Object[] args) in c:\\Program Files\\Microsoft Application Blocks For .Net\\User Interface Process 2.0\\Code\\Microsoft.ApplicationBlocks.UIProcess\\Factories\\GenericFactory.cs:line 73"

    Although the exception message says "The system cannot find the file specified", the assembly, named "MAJ.MyApp.Common.dll", does exist in the Common\bin\Debug folder.

    I just can't see what is causing this problem. Could anyone suggest a probable cause and solution?

    Thanks.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Mar 2006
    Posts
    15
    Quote Originally Posted by Phil Weber
    Thank you, Phil. I'll read through it.

    I am posting the exception message from SharpDevelop 2.0 beta as it might shed more light - as far as I can see, though, the version and public key token are correct (I have not set a public key token)

    Exception Microsoft.ApplicationBlocks.UIProcess.UIPException was thrown in debugee:
    The assembly MAJ.MyApp.Common,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null could not be loaded. Please check that the assembly type is fully qualified and is of format that follows. Also be sure that the version and public key token are correct. The correct format is: type="Microsoft.ApplicationBlocks.UIProcess.Samples.AddressWizard.WizardController, Microsoft.ApplicationBlocks.UIProcess.Samples.AddressWizard, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d69d63db1380c14d"The original exception is: Could not load file or assembly 'MAJ.MyApp.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

    Create() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\Factories\GenericFactory.cs:82,4
    Create() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\Factories\ControllerFactory.cs:54,4
    StartTask() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\Navigators\OpenNavigator.cs:200,4
    StartTask() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\Navigators\OpenNavigator.cs:195,4
    StartTask() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\Navigators\OpenNavigator.cs:151,4
    StartTask() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\Navigators\OpenNavigator.cs:110,7
    StartOpenNavigationTask() - c:\Program Files\Microsoft Application Blocks For .Net\User Interface Process 2.0\Code\Microsoft.ApplicationBlocks.UIProcess\UIPManager.cs:157,4
    Main() - D:\Work\MyApp\WinUILauncher\AppStart.vb:9,5

  4. #4
    Join Date
    Mar 2006
    Posts
    15

    Thumbs up

    Doh!... <slaps forehead>

    The solution just occured to me after my previous post when I realised my 'WinUILauncher' project (that starts the application via the UIPManager) needed a reference to the 'Common' project as, although my code doesn't reference it, the User Interface Process Application Block assembly referenced in the WinUILauncher project does need to reference the Common assembly as it uses the MyController class within it.

    The obvious answer can appear so elusive sometimes!
    Last edited by mjtech; 03-29-2006 at 08:05 PM.

Similar Threads

  1. CMR problem
    By vikassheelgupta in forum Java
    Replies: 0
    Last Post: 07-22-2005, 05:35 AM
  2. Replies: 4
    Last Post: 06-24-2005, 01:40 AM
  3. Java Applet Compiler problem?
    By mdl in forum Java
    Replies: 3
    Last Post: 03-07-2005, 02:34 AM
  4. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 04:40 AM
  5. Replies: 1
    Last Post: 08-01-2000, 01:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center