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

비밀번호

댓글 작성자
 




1  2  3  4  [5]  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13866정성태1/16/20256814개발 환경 구성: 739. Windows 10부터 바뀐 device driver 서명 방법
13865정성태1/15/20256041오류 유형: 942. C# - .NET Framework 4.5.2 이하의 버전에서 HttpWebRequest로 https 호출 시 "System.Net.WebException" 예외 발생
13864정성태1/15/20256013Linux: 114. eBPF를 위해 필요한 SELinux 보안 정책
13863정성태1/14/20254552Linux: 113. Linux - 프로세스를 위한 전용 SELinux 보안 문맥 지정
13862정성태1/13/20255206Linux: 112. Linux - 데몬을 위한 SELinux 보안 정책 설정
13861정성태1/11/20255437Windows: 276. 명령행에서 원격 서비스를 동기/비동기로 시작/중지
13860정성태1/10/20254892디버깅 기술: 216. WinDbg - 2가지 유형의 식 평가 방법(MASM, C++)
13859정성태1/9/20255760디버깅 기술: 215. Windbg - syscall 이후 실행되는 KiSystemCall64 함수 및 SSDT 디버깅
13858정성태1/8/20256010개발 환경 구성: 738. PowerShell - 원격 호출 시 "powershell.exe"가 아닌 "pwsh.exe" 환경으로 명령어를 실행하는 방법
13857정성태1/7/20256169C/C++: 187. Golang - 콘솔 응용 프로그램을 Linux 데몬 서비스를 지원하도록 변경파일 다운로드1
13856정성태1/6/20254835디버깅 기술: 214. Windbg - syscall 단계까지의 Win32 API 호출 (예: Sleep)
13855정성태12/28/20246674오류 유형: 941. Golang - os.StartProcess() 사용 시 오류 정리
13854정성태12/27/20246563C/C++: 186. Golang - 콘솔 응용 프로그램을 NT 서비스를 지원하도록 변경파일 다운로드1
13853정성태12/26/20245242디버깅 기술: 213. Windbg - swapgs 명령어와 (Ring 0 커널 모드의) FS, GS Segment 레지스터
13852정성태12/25/20246717디버깅 기술: 212. Windbg - (Ring 3 사용자 모드의) FS, GS Segment 레지스터파일 다운로드1
13851정성태12/23/20245589디버깅 기술: 211. Windbg - 커널 모드 디버깅 상태에서 사용자 프로그램을 디버깅하는 방법
13850정성태12/23/20247077오류 유형: 940. "Application Information" 서비스를 중지한 경우, "This file does not have an app associated with it for performing this action."
13849정성태12/20/20247028디버깅 기술: 210. Windbg - 논리(가상) 주소를 Segmentation을 거쳐 선형 주소로 변경
13848정성태12/18/20246414디버깅 기술: 209. Windbg로 알아보는 Prototype PTE파일 다운로드2
13847정성태12/18/20246289오류 유형: 939. golang - 빌드 시 "unknown directive: toolchain" 오류 빌드 시 이런 오류가 발생한다면?
13846정성태12/17/20247045디버깅 기술: 208. Windbg로 알아보는 Trans/Soft PTE와 2가지 Page Fault 유형파일 다운로드1
13845정성태12/16/20245546디버깅 기술: 207. Windbg로 알아보는 PTE (_MMPTE)
13844정성태12/14/20247662디버깅 기술: 206. Windbg로 알아보는 PFN (_MMPFN)파일 다운로드1
13843정성태12/13/20245639오류 유형: 938. Docker container 내에서 빌드 시 error MSB3021: Unable to copy file "..." to "...". Access to the path '...' is denied.
13842정성태12/12/20245832디버깅 기술: 205. Windbg - KPCR, KPRCB
13841정성태12/11/20246571오류 유형: 937. error MSB4044: The "ValidateValidArchitecture" task was not given a value for the required parameter "RemoteTarget"
1  2  3  4  [5]  6  7  8  9  10  11  12  13  14  15  ...