Piszę projekt w oparciu o ten przykład: http://www.codeproject.com/Articles/22761/Model-View-Presenter-Using-Dependency-Injection-an
Wszystko było fajnie, póki nie stwierdziłam, że czas już iść do promotora. Zgrałam projekt na laptopa, odpalam, nie działa -_-'
Na stacjonarce mam Win7, na laptopie to samo WinXP. Na obu VS jest w wersji 2010 Ultimate. Na stacjonarce projekt odpala się i działa. (Przed chwilą sprawdziłam jeszcze na trzecim kompie, WinXP + VS2010 Express - działa).
Na laptopie natomiast pierwszy błąd jaki napotkałam to: "Zestaw nie zezwala na częściowo zaufane obiekty wywołujące." (Wyjątek rzucony w momencie wywołania ContextRegistry.GetContext())
Na to pomogło dodanie do app.config fragmentu:
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
Pomogło o tyle, że teraz rzuca nowy wyjątek:
"Inicjator typów zgłosił wyjątek dla typu 'Spring.Context.Support.ContextRegistry'."
InnerException: "Could not configure Common.Logging from configuration section 'common/logging'."
No ba, nic dziwnego, że nie może tego skonfigurować w sekcji, bo nie ma takiej sekcji. A powinna być? Wcześniej jakoś nie była wymaga. Na dwóch innych komputerach nie jest wymaga...
App.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="HostModel" type="MvpExample.HostModel, MvpExample"/>
<object id="NetworkController" type="MvpExample.NetworkController, MvpExample">
<!-- <property name="HostModel" ref="HostModel"/>-->
</object>
<object id="SimulationView" type="MvpExample.SimulationView, MvpExample">
<property name="NetworkController" ref="NetworkController"/>
</object>
<object id="LogonService" type="MvpExample.LogonService, MvpExample"/>
<object id="LogonController" type="MvpExample.LogonController, MvpExample">
<property name="LogonService" ref="LogonService"/>
</object>
<object id="LogonView" type="MvpExample.LogonForm, MvpExample">
<property name="LogonController" ref="LogonController"/>
</object>
</objects>
</spring>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
Program.cs
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
IApplicationContext ctx = ContextRegistry.GetContext();
Form simForm = ctx.GetObject("SimulationView") as Form;
Application.Run(simForm);
}