خواندنیهای 29 مرداد
اس کیوال سرور
الگوهای طراحی برنامه نویسی شیءگرا
توسعه وب
دات نت فریم ورک
دبلیو پی اف و سیلور لایت
سی و مشتقات
متفرقه
محیطهای مجتمع توسعه
مرورگرها
پی اچ پی
این نگارش بر روی سیستم من مشکلی نداشت ولی پس از چند گزارش عدم امکان اجرای آن بر روی سایر سیستمها، یک ماشین مجازی ویندوز 8.1 را تهیه و برنامه را بر روی آن اجرا کردم. بله ... برنامه هنوز به مرحلهی نمایش نرسیده، محو میشد. در این مرحلهی ابتدایی امکان تهیهی لاگ استثنای حاصل توسط برنامه وجود نداشت و تنها این خطا در event viewer ویندوز (Computer management -> event viewer -> windows logs -> application) قابل مشاهده بود:
Application: DNTProfiler.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Windows.Markup.XamlParseException Stack: at System.Windows.Markup.WpfXamlLoader.Load
روش حل این نوع مشکلات و بررسی آنها در خارج از VS.NET، با استفاده از برنامهی معروف WinDBG مایکروسافت میسر است.
دو نگارش 32 بیتی و 64 بیتی آنرا از اینجا میتوانید دریافت کنید:
http://codemachine.com/downloads.html
پس از دریافت، بهتر است نسخهی 32 بیتی آنرا اجرا کنید، زیرا برای دیباگ برنامههای دات نت این نسخه است که امکان بارگذاری فایل C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll را دارد.
تا اینجا فرض بر این است که نسخهی 32 بیتی windbg را دریافت و اجرا کردهاید. در ادامه از منوی File آن گزینهی Open executable را انتخاب کرده و فایل exe برنامه را به آن معرفی کنید.
CommandLine: C:\Tests\DNTProfiler.1.0.808.0\DNTProfiler.exe Symbol search path is: srv* Executable search path is: ModLoad: 00150000 00176000 DNTProfiler.exe ModLoad: 76f30000 77098000 ntdll.dll ModLoad: 72ee0000 72f36000 C:\Windows\SysWOW64\MSCOREE.DLL ModLoad: 74be0000 74d20000 C:\Windows\SysWOW64\KERNEL32.dll ModLoad: 756e0000 757af000 C:\Windows\SysWOW64\KERNELBASE.dll (684.764): Break instruction exception - code 80000003 (first chance) eax=00000000 ebx=00000000 ecx=37af0000 edx=00000000 esi=7eb8f000 edi=00000000 eip=76fe2d15 esp=002ff604 ebp=002ff630 iopl=0 nv up ei pl zr na pe nc cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000246 *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll - ntdll!LdrResolveDelayLoadsFromDll+0xa89: 76fe2d15 cc int 3
0:000> g ModLoad: 757b0000 75827000 C:\Windows\SysWOW64\ADVAPI32.dll ModLoad: 05080000 05102000 Newtonsoft.Json.dll (684.764): C++ EH exception - code e06d7363 (first chance) (684.764): C++ EH exception - code e06d7363 (first chance) (684.764): C++ EH exception - code e06d7363 (first chance) (684.764): CLR exception - code e0434352 (first chance) First chance exceptions are reported before any exception handling. This exception may be expected and handled. eax=002fd0a0 ebx=00000005 ecx=00000005 edx=00000000 esi=002fd164 edi=00000001 eip=756f3d67 esp=002fd0a0 ebp=002fd0f8 iopl=0 nv up ei pl nz ac pe nc cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00200216 *** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\SysWOW64\KERNELBASE.dll - KERNELBASE!RaiseException+0x48: 756f3d67 8b4c2454 mov ecx,dword ptr [esp+54h] ss:002b:002fd0f4=3fce1188
0:000> sxe clr 0:000> g (684.764): C++ EH exception - code e06d7363 (first chance) (684.764): CLR exception - code e0434352 (first chance) First chance exceptions are reported before any exception handling. This exception may be expected and handled. eax=002fe2a0 ebx=00000005 ecx=00000005 edx=00000000 esi=002fe368 edi=00000001 eip=756f3d67 esp=002fe2a0 ebp=002fe2fc iopl=0 nv up ei pl nz ac pe nc cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00200216 KERNELBASE!RaiseException+0x48: 756f3d67 8b4c2454 mov ecx,dword ptr [esp+54h] ss:002b:002fe2f4=3fce2388
اکنون میخواهیم پیام استثنای واقعی دات نت را مشاهده کنیم. به همین جهت ابتدا دستور loadby sos clr! و سپس دستور CLRStack! را صادر میکنیم:
0:000> !loadby sos clr 0:000> !CLRStack *** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll - PDB symbol for clr.dll not loaded OS Thread Id: 0x764 (0) Child SP IP Call Site 002fe3f4 756f3d67 [GCFrame: 002fe3f4] 002fe430 756f3d67 [GCFrame: 002fe430] 002fe528 756f3d67 [GCFrame: 002fe528] 002fe544 756f3d67 [HelperMethodFrame_2OBJ: 002fe544] System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef) DNTProfiler.App.Main() 002ff190 720e2652 [GCFrame: 002ff190]
0:000> !PrintException Exception object: 021e6f0c Exception type: System.Reflection.TargetInvocationException Message: Exception has been thrown by the target of an invocation. InnerException: System.IO.FileNotFoundException, Use !PrintException 021e6950 to see more. StackTrace (generated): <none> StackTraceString: <none> HResult: 80131604 0:000> !PrintException 021e6950 Exception object: 021e6950 Exception type: System.IO.FileNotFoundException Message: Could not load file or assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. InnerException: <none> StackTrace (generated): SP IP Function 00000000 00000001 DNTProfiler!DNTProfiler.Services.SelfHostConfig.getHostConfiguration(System.String, Boolean)+0x2 002FE298 006B4E54 DNTProfiler!DNTProfiler.Services.SelfHostConfig.OpenWait(System.String, Boolean)+0x14 002FE2B0 006B4A3F DNTProfiler!DNTProfiler.ViewModels.MainWindowViewModel.doStart(System.String)+0x1f 002FE2C0 006B368D DNTProfiler!DNTProfiler.ViewModels.MainWindowViewModel..ctor(DNTProfiler.Common.Mvvm.ICommonDialogsService, DNTProfiler.Common.Controls.DialogManagement.Contracts.IDialogManager)+0xcd 002FE2D8 006B04C9 DNTProfiler!DNTProfiler.MainWindow..ctor()+0x91 StackTraceString: <none> HResult: 80070002
روش حل این مشکل، مراجعه به خواص پروژه، یافتن اسمبلی System.Net.Http.Formatting در لیست ارجاعات برنامه و سپس true کردن خاصیت copy to local آن است. به این ترتیب این اسمبلی در کنار فایل اجرایی برنامه کپی خواهد شد.
بنابراین خلاصهی عملیات یافتن علت اصلی کرش برنامه در خارج از ویژوال استودیو به صورت ذیل است:
الف) اجرای نسخهی 32 بیتی برنامهی windbg
ب) انتخاب منوی File آن و سپس باز کردن فایل اجرایی برنامه توسط گزینهی Open executable
ج) اجرای دستورات ذیل به ترتیب:
0:000> g 0:000> sxe clr 0:000> g 0:000> !loadby sos clr 0:000> !CLRStack 0:000> !PrintException
چند نمونهی مشابه برای مطالعهی بیشتر
Finding CLR exceptions without visual studio
Power of WinDBG: The story of mysterious crash of WPF application
In .NET 6 (preview 4), two long-awaited types have been introduced as part of the core library. DateOnly and TimeOnly allow developers to represent either the date or time portion of a DateTime. These two new types are structs (value types) and may be used when your code deals with date or time concepts independently. Both types can be found in the System namespace. Using these new types may align well with how databases allow similar data to be represented. Specifically, these types align well with the SQL Server date and time data types.
Build Real App in Angular 10 and ASP.Net Web API
These are 2 of the hottest frameworks right now for the ‘back-end’ (Microsoft’s ASP.NET Core) and the ‘front-end’ (Google’s Angular) and are well worth spending the time to learn.
This course starts from scratch, you neither need to know Angular 1 nor Angular 2
We will start from nothing and incrementally build this property dealing application front-end using Angular 10.
And then we will connect our front-end with the Web-API until we have a fully functional Web Application that we will publish to Firebase and then on IIS.
<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- To customize the asp.net core module uncomment and edit the following section. For more info see https://go.microsoft.com/fwlink/?linkid=838655 --> <system.webServer> <handlers> <remove name="aspNetCore"/> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModulev2" resourceType="Unspecified"/> </handlers> <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"> <handlerSettings> <handlerSetting name="experimentalEnableShadowCopy" value="true" /> <handlerSetting name="shadowCopyDirectory" value="../ShadowCopyDirectory/" /> <!-- Only enable handler logging if you encounter issues--> <!--<handlerSetting name="debugFile" value=".\logs\aspnetcore-debug.log" />--> <!--<handlerSetting name="debugLevel" value="FILE,TRACE" />--> </handlerSettings> </aspNetCore> </system.webServer> </configuration>