Friday, May 2, 2014

Global Assembly Cache Tool - Gacutil.exe

Gacutil.exe can help to view and manipulate the global assembly cache and download cache. Visual Studio installs the tool and it needs to run using the Developer Command Prompt.
gacutil [options] [assemblyName]


Share/Bookmark

Wednesday, April 30, 2014

Assembly Binding Log Viewer - fuslogvw.exe

When assembly binding fails, typically with an exception (usually, FileNotFoundException, FileLoadException, or BadImageFormatException).

At this point the Assembly Binding Log Viewer (fuslogvw.exe) which comes with .NET framework or The Microsoft .NET Framework SDK, I used it with .NET 4.5 the last time and through Developer Command Prompt for VS2013 which ran as Administrator.

When the binding happens, it looks like a Fusion, and "the Assembly Binding Log Viewer" will show you all assembly binds providing the HKLM\Software\Microsoft\Fusion\ForceLog registry value gets set to 1.

To force it to log I did the following setting in registery (by regedit.exe) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion Add: DWORD ForceLog set value to 1 DWORD LogFailures set value to 1 DWORD LogResourceBinds set value to 1

My problem which caught me was about signing assemblies which were strongly named in addition to assembly versioning.

Sample log will be something like the following (but this one is a successful binding sample):
*** Assembly Binder Log Entry (4/28/2014 @ 2:30:11 PM) *** The operation was successful. Bind result: hr = 0x0. The operation completed successfully. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable C:\Program Files (x86)\IIS Express\iisexpress.exe --- A detailed error log follows. === Pre-bind state information === LOG: DisplayName = Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///D:/appBranch/DEV-R2/LT/Services/Authentication/Authentication/ LOG: Initial PrivatePath = D:\appBranch\DEV-R2\LT\Services\Authentication\Authentication\bin LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f388dcb0 LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f388dcb0 LOG: AppName = 90e27310 Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: D:\LandTitles\DEV-R2\LT\Services\Authentication\Authentication\web.config LOG: Using host configuration file: C:\Users\Farhad.Bayanati\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a LOG: Found assembly by looking in the GAC. LOG: Binding succeeds. Returns assembly from C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll. LOG: Assembly is loaded in default load context.

Share/Bookmark

Monday, April 28, 2014

How to get Assembly full name(VersionNo, Culture, PublickeyToken)

In Visual Studio, Open a project, Debug Menu-->Windows-->Immediate
Shortcut: (Alt + Ctrl + i) or (Ctrl + D, I) open the Immediate Window

?System.Reflection.Assembly.LoadFile(@"C:\Path\YourAssemblyName.dll").FullName


P.S.
If you can't see the immediate window:
I am guessing that you picked a profile that hides this window.
Try: Tools->Import and Export settings->Reset all settings, and pick general development settings.

If you encoutered with following message:
"Design time expression evaluation for class libraries requires the Visual Studio hosting process which is unavailable in this debugging configuration."
Be sure in the project "Enable the Visual Studio hosting process" is checked, enabled.
Be sure in the project "Enable the Visual Studio hosting process" is checked, enabled.

The host process which is pointed to in above message refers to a feature of the CLR, Hosting allows one to configure the CLR before it gets started. One primary use of this is configuring the primary AppDomain and setting up custom security policies. Which is exactly what the hosting process is doing. in debug mode you are running with a customized version of the CLR, one that improves the debugging experience.


Share/Bookmark

Thursday, March 20, 2014

Physical DB and Log File location

A reminder!
USE [DB Name] GO SELECT * FROM sys.database_files

Share/Bookmark

Tuesday, February 25, 2014

C# - LINQ - Flatten nested Lists

Enumerable.SelectMany<TSource, TResult> Method (IEnumerable<TSource>, Func<TSource, IEnumerable<TResult>>)

Projects each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence.

IEnumerable group = new List(); // Select gets a list of lists of phone numbers IEnumerable> phoneLists = group.Select(g => g.Phones); // SelectMany flattens nested lists of phone numbers to a single list List phoneNumbers = group.SelectMany(g => g.Phones).ToList(); public class Phone { public string Number { get; set; } } public class Member { public IEnumerable Phones { get; set; } }

Share/Bookmark

Tuesday, January 21, 2014

A custom exception class with Log flag

A class to re-thrown Exception with property if the Exception is already logged.

[Serializable()] public class ExceptionLog : Exception { private bool isLogged; public bool IsLogged { get { return isLogged; } } protected ExceptionLog() : base() { } public ExceptionLog(bool value) : base() { isLogged = value; } public ExceptionLog(bool value, string message) : base(message) { isLogged = value; } public ExceptionLog(bool value , string message , Exception innerException) : base(message, innerException) { isLogged = value; } protected ExceptionLog(SerializationInfo info , StreamingContext context) : base(info, context) { } }

Share/Bookmark

Friday, January 3, 2014

Split Camel Case "string" To Human Readable

private string SplitCamelCaseToHumanReadable(string strCamelCase) { var rgx = new Regex( @"(?<=[A-Z])(?=[A-Z][a-z]) | (?<=[^A-Z])(?=[A-Z]) | (?<=[A-Za-z])(?=[^A-Za-z])" , RegexOptions.IgnorePatternWhitespace); return rgx.Replace(strCamelCase, " "); }

Share/Bookmark

Tuesday, December 31, 2013

Firebug Net panel - HTTP Traffic Monitoring

Needed to collect info around request URL, request header, response status, and response value of REST service calls, I utilized Net panel of Firebug which provided me a lot of details to verify the service calls processes in the web application.

The goal of using the Net panel was monitoring the HTTP traffic initiated by a web page which simply revealed all the collected and computed information in a graphical and intuitive interface.





introduction of Firebug by Rob Campbell


Share/Bookmark

IIS 7.5 Advanced Logging

To be able to capture all requests URLs and status of them in a real-time manner during a load test I added IIS Advanced Logging and customized it by defining the log, setting, and activating it.

It helped to monitor the sequence of requests and status of service responses during a load test.




Share/Bookmark

Trace listener and logging trace in a file

Possible to create and use a trace listener in code or by using a configuration file, as it’s easier to change configuration file without touching the code I tried to add it for a WebApi REST service by the following code for Telerik reports:

<system.diagnostics> <trace autoflush="false" indentsize="4"> <listeners> <add name="WebApiRESTListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="Services.Reporting.REST.Tracing.log" /> <remove name="Default" /> </listeners> </trace> </system.diagnostics>

Share/Bookmark