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

비밀번호

댓글 작성자
 




... 91  92  93  94  95  96  97  98  99  [100]  101  102  103  104  105  ...
NoWriterDateCnt.TitleFile(s)
11477정성태4/8/201819184오류 유형: 460. windbg - sos 명령어 수행 시 c0000006 오류 발생
11476정성태4/8/201820506디버깅 기술: 114. windbg - !threads 출력 결과로부터 닷넷 관리 스레드(System.Threading.Thread) 객체를 구하는 방법
11475정성태3/28/201823418디버깅 기술: 113. windbg - Thread.Suspend 호출 시 응용 프로그램 hang 현상에 대한 덤프 분석
11474정성태3/27/201821745오류 유형: 459. xperf: error: TEST.Event: Invalid flags. (0x3ec).
11473정성태3/22/201826714.NET Framework: 734. C# - Thread.Suspend 호출 시 응용 프로그램 hang 현상파일 다운로드2
11472정성태3/22/201820050개발 환경 구성: 356. GTX 1070, GTX 960, GT 640M의 cudaGetDeviceProperties 출력 결과
11471정성태3/20/201823128VC++: 125. CUDA로 작성한 RGB2RGBA 성능 [1]파일 다운로드1
11470정성태3/20/201826194오류 유형: 458. Visual Studio - CUDA 프로젝트 빌드 시 오류 C1189, expression must have a constant value
11469정성태3/19/201819240오류 유형: 457. error MSB3103: Invalid Resx file. Could not load file or assembly 'System.Windows.Forms, ...' or one of its dependencies.
11468정성태3/19/201818073오류 유형: 456. 닷넷 응용 프로그램 실행 시 0x80131401 예외 발생
11467정성태3/19/201818259오류 유형: 455. Visual Studio Installer - 업데이트 실패
11466정성태3/18/201818342개발 환경 구성: 355. 한 대의 PC에서 2개 이상의 DirectX 게임을 실행하는 방법
11463정성태3/15/201820649.NET Framework: 733. 스레드 간의 read/write 시에도 lock이 필요 없는 경우파일 다운로드1
11462정성태3/14/201824752개발 환경 구성: 354. HTTPS 호출에 대한 TLS 설정 확인하는 방법 [1]
11461정성태3/13/201826789오류 유형: 454. 윈도우 업데이트 설치 오류 - 0x800705b4 [1]
11460정성태3/13/201818674디버깅 기술: 112. windbg - 닷넷 메모리 덤프에서 전역 객체의 내용을 조사하는 방법
11459정성태3/13/201820160오류 유형: 453. Debug Diagnostic Tool에서 mscordacwks.dll을 찾지 못하는 문제
11458정성태2/21/201821040오류 유형: 452. This share requires the obsolete SMB1 protocol, which is unsafe and could expose your system to attack. [1]
11457정성태2/17/201825010.NET Framework: 732. C# - Task.ContinueWith 설명 [1]파일 다운로드1
11456정성태2/17/201831127.NET Framework: 731. C# - await을 Task 타입이 아닌 사용자 정의 타입에 적용하는 방법 [7]파일 다운로드1
11455정성태2/17/201820489오류 유형: 451. ASP.NET Core - An error occurred during the compilation of a resource required to process this request.
11454정성태2/12/201829560기타: 71. 만료된 Office 제품 키를 변경하는 방법
11453정성태1/31/201821264오류 유형: 450. Azure Cloud Services(classic) 배포 시 "Certificate with thumbprint ... doesn't exist." 오류 발생
11452정성태1/31/201826528기타: 70. 재현 가능한 최소한의 예제 프로젝트란? [3]파일 다운로드1
11451정성태1/24/201820297디버깅 기술: 111. windbg - x86 메모리 덤프 분석 시 닷넷 메서드의 호출 인자 값 확인
11450정성태1/24/201837059Windows: 146. PowerShell로 원격 프로세스(EXE, BAT) 실행하는 방법 [1]
... 91  92  93  94  95  96  97  98  99  [100]  101  102  103  104  105  ...