Unhandled ModuleLoadException

Topics: CAB & Smart Client Software Factory
Feb 7, 2006 at 11:38 AM
originally posted by: marekn

Hello,

I have problem with loading modules.

I have two projects: MainApp and Module1. In MainApp project there is FormShellApplication which consumes service provided by Module1. So Module1 need to be loaded before FormShellApplication is created. In MainApp's AssemblyInfo file I've added attribute: assembly: ModuleDependency("Module1") and I've also added file ProfileCatalog.xml (with option 'Copy always'):

<?xml version="1.0" encoding="utf-8" ?>
<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" >
<Modules>
<ModuleInfo AssemblyFile="Module1.dll" />
</Modules>
</SolutionProfile>

But when I start debugging solution there is unhandled ModuleLoadException "A module declared a dependency on another module which is not declared to be loaded. Missing module(s): Module1".

What I've done wrong?

Thanks for help
Marek
Feb 7, 2006 at 11:59 AM
originally posted by: DLorenz

Does it work if you remove the entry from the ProfileCatalog?
Feb 7, 2006 at 12:03 PM
originally posted by: marekn

No, it doesn't work.
Feb 7, 2006 at 12:10 PM
originally posted by: DLorenz

This is a post from long ago that someone said to do:

"In AssemblyInfo under properties in the project that needs the other assembly loaded you set the Module dependency like this.

assembly: Module("y")
assembly: ModuleDependency("x")

Hope it helps.
Cheers "
Feb 7, 2006 at 12:20 PM
originally posted by: marekn

I've seen this post, it works for egzample in this scenario: there are two modules:

<?xml version="1.0" encoding="utf-8" ?>
<SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" >
<Modules>
<ModuleInfo AssemblyFile="Module2.dll" />
<ModuleInfo AssemblyFile="Module1.dll" />
</Modules>
</SolutionProfile>

and Module1 depends on Module2. It still doesn't work if MainApp depends on Module1 (or Module2).
Feb 7, 2006 at 12:24 PM
originally posted by: DLorenz

My guess is that you would have to turn it into a service and have the MainApp use a ServiceDependancy tag.
Feb 7, 2006 at 12:34 PM
originally posted by: marekn

I've tried this:

public partial class MainForm : Form
{
.....
Module1.MyService myService;
ServiceDependency
public Module1.MyService MyService
{
set
{
this.myService = value;
}
}
.....
}

and if I remove ModuleDependency attribute form MainApp's AssemblyInfo, there is unhandled ServiceMissingException : "Service Module1.MyService is not available in the current context.".
Feb 7, 2006 at 12:41 PM
originally posted by: DLorenz

Try adding the service dependancy stuff into your Root Workitem. If that doesn't work, I guess the Microsoft guys will have to answer your question. I haven't really used any of the service stuff, nor needed to load other modules before loading the UI. Why exactly do you need to run this module before the main application?
Feb 8, 2006 at 12:05 AM
originally posted by: marekn

I work on redesign an old application using CAB. In MainFrom (or MainFromController) there are some places when I need to call a service from the other module. And that's way the odher module must be loaded before MainFrom is created.
Oct 21, 2006 at 6:58 AM
originally posted by: kovlab49

Just a few sanity tests: in Module1, you've declared MyService to be public, and has a Service attribute?

Service
public class MyService { ...}

Other note: since MainForm references it directly, you must have an assembly reference from the main assembly to the Module1 assembly, so I kind of think you don't even need a profilecatalog.xml but I'm not certain about that.
Nov 8, 2006 at 5:05 AM
originally posted by: DimaDNK

i've got this problem too =(
it seem's like assembly: ModuleDependency("Module1") feature does not work.

I tuned off any services and tryed to load module through assembly: ModuleDependency("Module1")
but it always raises exception (with SolutionProfile or without it).
(sorry for my english)

awaiting comments.