Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

디버깅 모드로 실행 시 "Could not find file 'C:\Program Files\IIS Express\Oracle.DataAccess.Common.Configuration.Section.xsd'" 예외

Visual Studio에서 디버깅 상태로 OracleConnection.Open 시에 이런 예외가 발생합니다.

System.IO.FileNotFoundException
  HResult=0x80070002
  Message=Could not find file 'C:\Program Files\IIS Express\Oracle.DataAccess.Common.Configuration.Section.xsd'.
  Source=mscorlib
  StackTrace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) in System.IO\__Error.cs:line 127

  This exception was originally thrown at this call stack:
    System.IO.__Error.WinIOError(int, string) in __Error.cs

물론 이것은 "FileNotFoundException" 예외에 대해 "Break when this exception type is thrown" 옵션을 켰기 때문이고 그렇지 않은 상황, 예를 들어 단순히 디버거 연결 없이 실행한 상황이라면 try/catch로 인해 지나가는 코드입니다.

따라서 FileNotFoundException의 "Break when ..." 옵션을 끄면 되지만, 개인적으로 first chance 예외에 이런 식으로 대응하는 것은 곧, 버그 생산의 시작이라고 생각하기 때문에 가능한 해결하는 식으로 진행하고 있습니다.

우선, 쉬운 해결 방법은 web.config에 있는 <oracle.manageddataaccess.client /> 노드를 삭제하는 것입니다. 제 경우에 다음과 같이 예제 차원에서 포함돼 있었는데요,

<?xml version="1.0" encoding="utf-8"?>

<configuration>

    <!-- 생략 -->

    <oracle.manageddataaccess.client>
        <version number="*">
            <dataSources>
                <dataSource alias="SampleDataSource"
                    descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
            </dataSources>
        </version>
    </oracle.manageddataaccess.client>
</configuration>

쓰지 않는 dataSource 설정이었기 때문에 제거했더니 FileNotFoundException 예외가 없어졌습니다. 반면, 저 설정을 사용해야 한다면... 연결 문자열에 해당하는 descriptor 정보를 configuration/connectionStrings 노드로 이전하는 것도 방법입니다.

만약, 그것도 싫다면...? ^^;

이게 좀 재미있는데요, 우선 저 예외가 발생하는 소스 코드를 살펴보면,

// CustomConfigFileReader.cs

[ReflectionPermission(SecurityAction.Assert, Unrestricted = true)]
internal void ValidateBaseDocument(XmlDocument doc)
{
	CustomConfigFileReader @object = new CustomConfigFileReader(ConfigBaseClass.m_bIsManaged);
	doc.Schemas.Add(null, new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Oracle.ManagedDataAccess.src.Common.Resources.Oracle.DataAccess.Common.Configuration.Section.xsd")));
	doc.Schemas.Add(null, new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("Oracle.ManagedDataAccess.src.Common.Resources.Oracle.ManagedDataAccess.Client.Configuration.Section.xsd")));
	ValidationEventHandler validationEventHandler = @object.ValidationCallBack;
	doc.Validate(validationEventHandler);
}

Oracle.ManagedDataAccess.dll의 리소스로 포함된 "Oracle.ManagedDataAccess.src.Common.Resources.Oracle.ManagedDataAccess.Client.Configuration.Section.xsd" 자원을 읽어내는 코드에서 시작합니다.

그리고 실제로도 저 리소스는 다음의 내용으로 포함돼 있고,

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:include schemaLocation="Oracle.DataAccess.Common.Configuration.Section.xsd"/>
  <xs:element name="oracle.manageddataaccess.client" >
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="version" type="odpmversiontype" minOccurs="0" />
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:complexType name="odpmversiontype">
    <xs:complexContent>
      <xs:extension base="odpmparameters">
        <xs:attribute name="number" type="xs:string" use="required" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="odpmparameters">
    <xs:all>
      <xs:element minOccurs="0" name="settings">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="setting">
              <xs:complexType>
                <xs:attribute name="name" type="xs:string" use="required" />
                <xs:attribute name="value" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element minOccurs="0" name="udtMappings">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="udtMapping">
              <xs:complexType>
                <xs:attribute name="typeName" type="xs:string" use="required" />
                <xs:attribute name="factoryName" type="xs:string" use="required" />
                <xs:attribute name="dataSource" type="xs:string" use="required" />
                <xs:attribute name="schemaName" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element minOccurs="0" name="LDAPsettings">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="LDAPsetting">
              <xs:complexType>
                <xs:attribute name="name" type="xs:string" use="required" />
                <xs:attribute name="value" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element minOccurs="0" name="distributedTransaction">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="setting">
              <xs:complexType>
                <xs:attribute name="name" type="xs:string" use="required" />
                <xs:attribute name="value" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element minOccurs="0" name="dataSources">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="dataSource">
              <xs:complexType>
                <xs:attribute name="alias" type="xs:string" use="required" />
                <xs:attribute name="descriptor" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>

      <xs:element minOccurs="0" name="connectionPools">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="connectionPool">
              <xs:complexType>
                <xs:attribute name="connectionString" type="xs:string" use="required" />
                <xs:attribute name="poolName" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>


      <xs:element minOccurs="0" name="edmMappings">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="edmMapping">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="unbounded" name="add">
                    <xs:complexType>
                      <xs:attribute name="name" type="xs:string" use="required" />
                      <xs:attribute name="precision" type="xs:int" use="required" />
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="dataType" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="edmNumberMapping">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="unbounded" name="add">
                    <xs:complexType>
                      <xs:attribute name="NETType" type="xs:string" use="required" />
                      <xs:attribute name="MinPrecision" type="xs:int" use="required" />
                      <xs:attribute name="MaxPrecision" type="xs:int" use="required" />
                      <xs:attribute name="DBType" type="xs:string" use="required" />
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element minOccurs="0" name="implicitRefCursor">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="storedProcedure">
              <xs:complexType>
                <xs:sequence>
                  <xs:element maxOccurs="unbounded" minOccurs="1" name="refCursor">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element maxOccurs="1" minOccurs="1" name="bindInfo">
                          <xs:complexType>
                            <xs:attribute name="mode" type="parameterDirection" use="required" />
                          </xs:complexType>
                        </xs:element>
                        <xs:element maxOccurs="unbounded" minOccurs="0" name="metadata">
                          <xs:complexType>
                            <xs:attribute name="columnOrdinal" type="xs:int" use="required" />
                            <xs:attribute name="columnName" type="xs:string" use="required" />
                            <xs:attribute name="baseColumnName" type="xs:string" use="optional" />
                            <xs:attribute name="baseSchemaName" type="xs:string" use="optional" />
                            <xs:attribute name="baseTableName" type="xs:string" use="optional" />
                            <xs:attribute name="providerType" type="providerType" use="optional" />
                            <xs:attribute name="columnSize" type="xs:int" use="optional" />
                            <xs:attribute name="numericPrecision" type="xs:int" use="optional" />
                            <xs:attribute name="numericScale" type="xs:int" use="optional" />
                            <xs:attribute name="isUnique" type="customBoolean" use="optional" />
                            <xs:attribute name="isKey" type="customBoolean" use="optional" />
                            <xs:attribute name="isRowID" type="customBoolean" use="optional" />
                            <xs:attribute name="dataType" type="datatype" use="optional" />
                            <xs:attribute name="allowDBNull" type="customBoolean" use="optional" />
                            <xs:attribute name="isAliased" type="customBoolean" use="optional" />
                            <xs:attribute name="isByteSemantic" type="customBoolean" use="optional" />
                            <xs:attribute name="isExpression" type="customBoolean" use="optional" />
                            <xs:attribute name="isHidden" type="customBoolean" use="optional" />
                            <xs:attribute name="isReadOnly" type="customBoolean" use="optional" />
                            <xs:attribute name="isLong" type="customBoolean" use="optional" />
                            <xs:attribute name="udtTypeName" type="xs:string" use="optional" />
                            <xs:attribute name="nativeDataType" type="nativeDataType" use="optional" />
                            <xs:attribute name="providerDBType" type="providerDBType" use="optional" />
                            <xs:attribute name="objectName" type="xs:string" use="optional" />
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                      <xs:attribute name="name" type="xs:string" use="optional" />
                      <xs:attribute name="position" type="xs:int" use="optional" />
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="schema" type="xs:string" use="optional" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element minOccurs="0" name="onsConfig">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="ons">
              <xs:complexType>
                <xs:sequence>
                  <xs:element maxOccurs="3" minOccurs="1" name="add">
                    <xs:complexType>
                      <xs:attribute name="name" type="ONSParameters" use="required" />
                      <xs:attribute name="value" type="xs:string" use="required" />
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="database" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="configFile" type="xs:string" use="optional" />
          <xs:attribute name="mode" type="ONSModeValues" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:all>
  </xs:complexType>
</xs:schema>

바로 저 파일의 "<xs:include schemaLocation="Oracle.DataAccess.Common.Configuration.Section.xsd"/>" 부분이 문제의 원인이 되는 것입니다. 이로 인해 결국 schema 파일을 처리하는 과정에서 XmlDownloadManager가 관여하게 되고,

internal class XmlDownloadManager
{
    private Hashtable connections;

    internal Stream GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
    {
        // uri == "{file:///C:/Program Files/IIS Express/Oracle.DataAccess.Common.Configuration.Section.xsd}"
        if (uri.Scheme == "file")
        {
            return new FileStream(uri.LocalPath, FileMode.Open, FileAccess.Read, FileShare.Read, 1);
        }
        return GetNonFileStream(uri, credentials, proxy, cachePolicy);
    }

    // ...[생략]...
}

현재의 "Current Directory"를 기준으로 한 경로에서 xsd 파일을 로드하려고 시도하므로 저런 예외가 발생하는 것입니다. 어쩔 수 없군요, 이런 경우 그냥 빈 xsd 파일을 하나 만들어,

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
</xs:schema>

"C:\Program Files\IIS Express" 폴더에 넣어주면 됩니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 7/11/2025]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 181  182  183  [184]  185  186  187  188  189  190  191  192  193  194  195  ...
NoWriterDateCnt.TitleFile(s)
426정성태12/30/200620856    답변글 기타: 16.1. 예외 발생
420정성태12/27/200625696Windows: 10. Internet Explorer 7.0 호환성 백서 (Word 문서, 1.92MB) [7]파일 다운로드1
419정성태12/25/200627326Windows: 9. VS.NET 2005 원격 디버깅 구성
418정성태12/25/200635406웹: 5. IIS 7에서 클라이언트 측 인증서 사용 시 주의점 [2]
417정성태12/24/200627764Windows: 8. VS.NET 2005에서의 웹 애플리케이션 디버깅 설정
416정성태1/31/200727884오류 유형: 23. MSI 설치 시 로그 파일 생성하는 레지스트리 설정 [3]
415정성태12/31/200631645개발 환경 구성: 20. 인증서 오류 체크 목록
413정성태12/20/200628457VC++: 26. volatile 키워드 [1]파일 다운로드1
412정성태12/17/200632475오류 유형: 22. VS.NET 2005 SP1 설치 도중 오류 [9]
411정성태12/16/200621439오류 유형: 21. TFS SP1 설치 관련 오류 (2) - KB919156 패치 이후 TFS 접근 문제
410정성태12/16/200622601오류 유형: 20. TFS SP1 설치 관련 오류 (1) - KB919156 패치
408정성태12/10/200624897Windows: 7. USB 드라이브 내용 암호화
407정성태12/10/200622212오류 유형: 19. Vista 에서의 VS.NET 2005 로 개발한 어셈블리에 대한 서명 확인 오류
406정성태12/10/200627118Windows: 6. IE 7 검색 공급자 - 영한 사전
403정성태12/6/200634260Windows: 5. Vista 와 웹 인증 등록 서비스의 문제 [5]
402정성태12/11/200625292Windows: 4. Vista 설치 후기 [1]
409정성태12/11/200629327    답변글 Windows: 4.1. Vista 설치 후기 - 두 번째 이야기 [3]
396정성태2/13/200731991오류 유형: 18. "Automatic Updates" 서비스 CPU 100% 점유 현상
393정성태11/8/200621467오류 유형: 17. Unable to start debugging - The binding handle is invalid.
371정성태10/23/200620753오류 유형: 16. STS Communication failed.
370정성태11/12/200624574.NET Framework: 75. Windows CardSpace 이야기 (이 글의 내용은 재작성되어질 예정입니다.)
375정성태10/25/200626493    답변글 .NET Framework: 75.1. 개인 발행 카드에 대한 Microsoft 예제 실습(이 글의 내용은 재작성되어질 예정입니다.)
376정성태10/27/200626195    답변글 .NET Framework: 75.2. "Windows CardSpace"와 "인증서 서비스"의 만남(이 글의 내용은 재작성되어질 예정입니다.)
377정성태10/26/200625955    답변글 .NET Framework: 75.3. Managed Card 발행에 대한 Microsoft 예제 실습 (1) - CardWriter (이 글의 내용은 재작성되어질 예정입니다.)
385정성태11/6/200628420    답변글 .NET Framework: 75.4. Managed Card 발행에 대한 Microsoft 예제 실습 (2) - STS 구현 (이 글의 내용은 재작성되어질 예정입니다.) [7]
387정성태11/2/200629401    답변글 .NET Framework: 75.5. Windows CardSpace와 SYSNET 사이트의 만남 (이 글의 내용은 재작성되어질 예정입니다.) [1]
... 181  182  183  [184]  185  186  187  188  189  190  191  192  193  194  195  ...