You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Germán Ubillos <gu...@gmail.com> on 2007/02/05 13:52:30 UTC

Problem when looking for configuration files in dynamic modules.

Hi, I´m having some trouble with ibatis 1.6 (and also with ibatis 1.5). I´m
building a web application and I hava a class name DALManager, that wraps an
ISqlMapper object. In the project where this DALManager class is, I have two
folders, Maps (with the SQLMap.xml) and Config (with the
providers.configand the
sqlmap.config files). This files are embedded in the assembly.
The code of the static initializer is the following one...

public partial class DALManager{
      static ISqlMapper my_mapper;

      static DALManager(){
          string connectionString =
ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;

          IBatisNet.DataMapper.Configuration.DomSqlMapBuilder conf = new
IBatisNet.DataMapper.Configuration.DomSqlMapBuilder();
          Assembly assembly = Assembly.GetExecutingAssembly();
          Stream stream = assembly.GetManifestResourceStream("
Dashboard.DAL.Config.SqlMap.config");
          XmlDocument sqlConf = new XmlDocument();
          sqlConf.Load(stream);
-------> my_mapper = conf.Configure(sqlConf);
          my_mapper.DataSource.ConnectionString = connectionString;
      }
      ... more methods...
}

Now, the problem I am having is that sometimes, when the static initializer
is invoked I get an exception in the line that is marked with -------> [
my_mapper = conf.Configure(sqlConf);]. I´m sending an attached file with the
exception that gets raised. I downloaded the Ibatis source code and
following it, I arrived to line 441 in the class Resources of the namespace
IBatisNet.Common.Utilities of the IBatisNet.Common assembly. The line is
[Stream stream = assembly.GetManifestResourceStream(fileInfo.FileName);] and
for some of the assemblies that the GetManifestResourceStream method it´s
invoked, the Not SupportedException gets raised. I modified the class´s
code, and placed this code inside a try catch block, doing nothing in the
catch. I would like to know if there is a better solution for this.
Unfortunately I wasn´t able to reproduce this in a simpler project (i will
try to). Anyway, I´m using ASP.net 2.0, Ajax extensions (the latest release,
I have a couple of resx files in the App_GlobalResources and I am also using
the css control adapter toolkit.
Hope this can contribute.
Regards, Germán