Why does Castle Windsor constructor crash on Windows Server 2003 with a manifest?

僤鯓⒐⒋嵵緔 提交于 2019-12-23 04:27:00

问题


As part of getting our application ready for Windows7, we recently added a manifest to our our user interface's exe.

It runs ok on Windows7. However, now when I try to run the signed exe on Windows Server 2003, the program crashes during startup. I've looked at the crash dump, and it seems to by failing in the constructor of Castle.Core.Resource.ConfigResource which is called from the Program.Main method.

If this is included in the manifest:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
        <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
        <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
</compatibility>

then it crashes, but if I comment it out and rebuild, it's ok.

Have you got any ideas about what could be causing the problem?


回答1:


Well, I still don't know the reason why it doesn't work, but I have a workaround.

Instead of loading the castle configuration from the app.config file with something like:

IWindsorContainer container =
    new WindsorContainer(
        new XmlInterpreter(new ConfigResource("castle")));

Move the config into a literal string and load it this way:

StaticContentResource scr = new StaticContentResource(
    @"<configuration>
        <!-- Move stuff that was originally in the app.config to here -->
    </configuration>"
    );
IWindsorContainer container = new WindsorContainer(new XmlInterpreter(scr));

It seems the problem is down to ConfigResource's constructor running this line:

XmlNode section = (XmlNode) ConfigurationManager.GetSection(sectionName);

this returns null if I use mt.exe to add a manifest to the console, but returns the expected value if I don't.



来源:https://stackoverflow.com/questions/1868219/why-does-castle-windsor-constructor-crash-on-windows-server-2003-with-a-manifest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!