Allow Resources.cs to process non-fullly-qualified-types --------------------------------------------------------
Key: IBATISNET-122 URL: http://issues.apache.org/jira/browse/IBATISNET-122 Project: iBatis for .NET Type: Bug Reporter: Ron Grabowski Assigned to: Ron Grabowski Priority: Minor IBatisNet should be able to handle loading a type if that type's assembly has already been loaded into the current domain. For example in log4net its possible to use this syntax: <appender name="FileAppender" type="log4net.Appender.FileAppender"> ... </appender> You don't need to specify the log4net assembly becuase the log4net assembly has already been loaded in the current domain. In other words, you can't tell log4net to process the log4net.config file unless the log4net assembly has been successfully loaded: <!-- log4net isn't required becuase the current domain has already loaded the log4net assembly --> <appender name="FileAppender" type="log4net.Appender.FileAppender, log4net"> ... </appender> The same thing can be applied to IBatisNet's handling of embedded resources. The GetEmbeddedResourceAsXmlDocument method of Resources.cs has the following code: public static XmlDocument GetEmbeddedResourceAsXmlDocument(string resource) { // snip FileAssemblyInfo fileInfo = new FileAssemblyInfo(resource); if (fileInfo.IsAssemblyQualified) { // snip } else { // bare type name... loop thru all loaded assemblies Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Stream stream = assembly.GetManifestResourceStream(fileInfo.FileName); // snip } } //snip } The important thing to note here is that IsAssemblyQualified will always be true. It can never be false which means the else block is never processed. The FileAssemblyInfo constructor calls through to SplitFileAndAssemblyNames: // WRONG private void SplitFileAndAssemblyNames (string originalFileName) { _originalFileName = originalFileName; int separatorIndex = originalFileName.IndexOf(FileAssemblyInfo.FileAssemblySeparator); if (separatorIndex < 0) { throw new ConfigurationException( string.Format("Unable to find assembly part to load embedded resource in string \"{0}\".", originalFileName)); } else { _unresolvedFileName = originalFileName.Substring(0, separatorIndex).Trim(); _unresolvedAssemblyName = originalFileName.Substring(separatorIndex + 1).Trim(); } } // CORRECT private void SplitFileAndAssemblyNames (string originalFileName) { _originalFileName = originalFileName; int separatorIndex = originalFileName.IndexOf(FileAssemblyInfo.FileAssemblySeparator); if (separatorIndex < 0) { _unresolvedFileName = originalFileName.Trim(); _unresolvedAssemblyName = null; // IsAssemblyQualified will return false } else { _unresolvedFileName = originalFileName.Substring(0, separatorIndex).Trim(); _unresolvedAssemblyName = originalFileName.Substring(separatorIndex + 1).Trim(); } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira