首页 新闻 赞助 找找看

Spring.NET遇到问题

0
悬赏园豆:10 [待解决问题]

 IApplicationContext ctx = ContextRegistry.GetContext();

aspx.cs页面这样写提示这样的问题

wwd东的主页 wwd东 | 初学一级 | 园豆:190
提问于:2011-12-06 11:10
< >
分享
所有回答(1)
0

按提示操作就行了,“Use the 'RegisterContext' method or the 'spring/context' section from your configration file.”,查查配置文件中是否配有'spring/context',如下内容:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="spring.xml.config"/>
</context>
</spring>
</configuration>

这样配置的目的是指定context.GetObject方法加载哪个配置文件。

LCM | 园豆:6876 (大侠五级) | 2011-12-06 11:24

<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="assembly://TestSpring/TestSpring/Objects.xml"/>
      <resource uri="config://spring/objects" />
    </context>
    <objects xmlns="http://www.springframework.net"/>
    <!--必要-->
  </spring>

</configuration>

这是我的App.config里面的,配置有错误吗?

支持(0) 反对(0) wwd东 | 园豆:190 (初学一级) | 2011-12-06 11:32

这样也不行的……IApplicationContext context = new XmlApplicationContext(xmlFiles);也是提示

支持(0) 反对(0) wwd东 | 园豆:190 (初学一级) | 2011-12-06 11:43

@wwd东: Objects.xml文件的路径正确吗?我以前只用过“file:”和“config:”开头的,没用过“assembly:”开头的。这个应该表示objects.xml是嵌入资源吧,那你看下嵌入资源路径有没有错误。

支持(0) 反对(0) LCM | 园豆:6876 (大侠五级) | 2011-12-06 17:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册