성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
[정성태] 저렇게 조각 코드 말고, 실제로 재현이 되는 예제 프로젝트를 압...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>ASP.NET - .NET Framework 기본 예제에서 System.Web에 대한 System.IO.FileNotFoundException 예외 발생</h1> <p> 이상하군요, 예전에는 안 그랬던 것 같은데 최근에 테스트할 일이 있어 생성했더니, Visual Studio의 Output 실행 로그에 System.IO.FileNotFoundException이 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > ...[생략]... 'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/2/ROOT-1-133528209075464738): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\vs\14fe66ee\42b634d7\App_Web_4wtwjhrw.dll'. Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll 'iisexpress.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. ...[생략]... </pre> <br /> <a target='tab' href='https://www.sysnet.pe.kr/2/0/10811#broken_windows'>역시 이번에도 ^^; 그냥 지나칠 수가 없군요,</a> 비주얼 스튜디오에서 "System.IO.FileNotFoundException" 예외에 대해 <a target='tab' href='https://www.sysnet.pe.kr/2/0/510'>Thrown 옵션을 켜면</a> 이런 예외 메시지를 보게 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly '<span style='color: blue; font-weight: bold'>System.Web</span>' or one of its dependencies. The system cannot find the file specified. Source=mscorlib StackTrace: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) in System.Reflection\RuntimeAssembly.cs:line 578 This exception was originally thrown at this call stack: System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, ref System.Threading.StackCrawlMark, System.IntPtr, bool, bool, bool) in RuntimeAssembly.cs </pre> <br /> 더불어 Call Stack 창을 보면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > > mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) Line 575 C# mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool forIntrospection) Line 511 C# mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoad(string assemblyString, System.Security.Policy.Evidence assemblySecurity, ref System.Threading.StackCrawlMark stackMark, bool forIntrospection) Line 498 C# mscorlib.dll!System.Reflection.Assembly.Load(string assemblyString) Line 538 C# System.Web.dll!System.Web.Configuration.CompilationSection.LoadAssembly(string assemblyName = "System.Web", bool throwOnFail = true) Unknown System.Web.Extensions.dll!System.Web.UI.AssemblyCache.Load(string assemblyName = "System.Web") Unknown System.Web.Extensions.dll!System.Web.UI.ScriptResourceMapping.GetDefinition(System.Web.UI.ScriptReference scriptReference) Unknown System.Web.Extensions.dll!System.Web.UI.ScriptReference.ScriptEffectiveInfo.ScriptEffectiveInfo(System.Web.UI.ScriptReference scriptReference = {System.Web.UI.ScriptReference}) Unknown System.Web.Extensions.dll!System.Web.UI.<span style='color: blue; font-weight: bold'>ScriptReference.GetAssembly</span>(System.Web.UI.ScriptManager scriptManager = {System.Web.UI.ScriptManager}) Unknown System.Web.Extensions.dll!System.Web.UI.ScriptReference.IsAjaxFrameworkScript(System.Web.UI.ScriptManager scriptManager = {System.Web.UI.ScriptManager}) Unknown System.Web.Extensions.dll!System.Web.UI.<span style='color: blue; font-weight: bold'>ScriptManager</span>.AddScriptCollections(System.Collections.Generic.List<System.Web.UI.ScriptReferenceBase> scripts = Count = 2, System.Collections.Generic.IEnumerable<System.Web.UI.ScriptManagerProxy> proxies = null) Unknown System.Web.Extensions.dll!System.Web.UI.ScriptManager.RegisterScripts() Unknown </pre> <br /> ScriptManager라는 점에서 "Site.Master" 파일에 있는,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication1.SiteMaster" %> <!DOCTYPE html> <html lang="en"> <head runat="server"> ...[생략]... </head> <body> <form runat="server"> <asp:ScriptManager runat="server"> <Scripts> <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%> <%--Framework Scripts--%> <asp:ScriptReference Name="MsAjaxBundle" /> <asp:ScriptReference Name="jquery" /> <span style='color: blue; font-weight: bold'><asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" /> <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" /> <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" /> <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" /> <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" /> <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" /> <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" /> <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" /></span> <asp:ScriptReference Name="WebFormsBundle" /> <%--Site Scripts--%> </Scripts> </asp:ScriptManager> ...[생략]... </body> </html> </pre> <br /> System.Web과 관련된 ScriptReference가 영향을 주는 듯합니다. 실제로, WebForms.js부터 Focus.js까지 주석 처리를 하면 FileNotFoundException 예외가 발생하지 않습니다.<br /> <br /> <hr style='width: 50%' /><br /> <br /> First-chance exception으로만 발생하고 Secondary-chance exception으로 연결이 안 된다는 점과, 해당 ScriptReference들이 모두 잘 동작한다는 점에서, 아마도 System.Web 이름으로 찾지 못했더라도 다른 식으로라도 로딩을 해 정상적으로 처리하는 것 같습니다.<br /> <br /> 단지, 저 오류를 디버그 창에서라도 보고 싶지 않다면 2가지 방법으로 처리할 수 있습니다. 첫 번째는, Global.asax.cs 파일에 "System.Web"에 대한 로딩 처리를 추가해 주는 것입니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > public class Global : HttpApplication { void Application_Start(object sender, EventArgs e) { <span style='color: blue; font-weight: bold'>#if DEBUG AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; #endif</span> // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); } <span style='color: blue; font-weight: bold'>private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { if (asm.GetName().Name == args.Name) { return asm; } } return null; }</span> } </pre> <br /> 저 코드가 싫다면, 두 번째 방법으로 Site.Master의 ScriptReference에 System.Web의 Strong name을 지정해도 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > <asp:ScriptReference Name="WebForms.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/WebForms.js" /> <asp:ScriptReference Name="WebUIValidation.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/WebUIValidation.js" /> <asp:ScriptReference Name="MenuStandards.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/MenuStandards.js" /> <asp:ScriptReference Name="GridView.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/GridView.js" /> <asp:ScriptReference Name="DetailsView.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/DetailsView.js" /> <asp:ScriptReference Name="TreeView.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/TreeView.js" /> <asp:ScriptReference Name="WebParts.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/WebParts.js" /> <asp:ScriptReference Name="Focus.js" Assembly="<span style='color: blue; font-weight: bold'>System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>" Path="~/Scripts/WebForms/Focus.js" /> </pre> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1771
(왼쪽의 숫자를 입력해야 합니다.)