Hi,
I've a problem that I can't solve.
The part in Bold gives always an "IndexOutOfRangeException".
Can somebody help???
public class MainViewModel : ViewModelBase
{
[Import(typeof(IJBAEnvironmentViewModel))]
public IJBAEnvironmentViewModel JBAEnvir { get; set; }
[ImportMany(AllowRecomposition = true)]
public Contracts.IScreen[] Screens { get; set; }
private string _JBAEnvironment;
private UserControl _Screen;
public string JBAEnvironment
{
get
{
return _JBAEnvironment;
}
set
{
_JBAEnvironment = value;
RaisePropertyChanged("JBAEnvironment");
}
}
public UserControl Screen
{
get
{
return _Screen;
}
set
{
_Screen = value;
RaisePropertyChanged("Screen");
}
}
public MainViewModel()
{
App.aggr.Catalogs.Add(CreateCatalog("JBAEnvir.xap"));
}
private DeploymentCatalog CreateCatalog(string uri)
{
DeploymentCatalog catalog = new DeploymentCatalog(new Uri(uri, UriKind.Relative));
CompositionHost.Initialize(catalog);
catalog.DownloadCompleted += (s, e) =>
{
if (e.Error != null)
{
string ssss = e.Error.Message;
}
else
{
CompositionInitializer.SatisfyImports(this);
JBAEnvironment = JBAEnvir.GetJBAEnvironment();
//JBAEnvir.Test(JBAEnvironment);
//IsUnderMaintenance = JBAEnvir.IsUnderMaintenance;
string thedate = DateTime.Now.ToString("yyyy-MM-d-HH.mm.ss.000000");
MaintenanceSvc.maintenanceServicePortTypeClient ctx = new MaintenanceSvc.maintenanceServicePortTypeClient(new BasicHttpBinding(), new EndpointAddress("http://myLink/maintenance.php"));
ctx.setMaintenanceCompleted += (ss, ee) =>
{
if (ee.Result.Equals("none"))
{
App.aggr.Catalogs.Add(CreateCatalog2("Start.xap"));
}
else
{
App.aggr.Catalogs.Add(CreateCatalog2("Maintenance.xap"));
}
};
ctx.setMaintenanceAsync(thedate);
}
};
catalog.DownloadAsync();
return catalog;
}
private DeploymentCatalog CreateCatalog2(string xap)
{
DeploymentCatalog catalog = new DeploymentCatalog(new Uri(xap, UriKind.Relative));
catalog.DownloadCompleted += (s, e) =>
{
if (e.Error != null)
{
string ss = e.Error.Message;
}
else
{
CompositionInitializer.SatisfyImports(this);
Screen = Screens[0].getUserControl();
}
};
catalog.DownloadAsync();
return catalog;
}
}