- Create .xsd/schema file
- Open Visual Studio Command Prompt
- Go to the location of the schema file
- Type => xsd /classes <schema_file.xsd>
- Above command will generate a <schema_file.cs>
Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts
Wednesday, November 9, 2016
Tuesday, March 5, 2013
C# | How to write entry to Windows Event
Here's a sample code on how to write to Windows Event Logs.
Keep an eye on variable maximumCharacterThatTheWindowEventLogsCanHandled where I used 30,000 but for it's actually 32,766 :)
Keep an eye on variable maximumCharacterThatTheWindowEventLogsCanHandled where I used 30,000 but for it's actually 32,766 :)
private static void WriteToWindowsEventLog(string logs)
{
const string source = "biboyatienza Sample Windows Services";
const string log = "Application";
const int maximumCharacterThatTheWindowEventLogsCanHandled = 30000;
if (!EventLog.SourceExists(source))
EventLog.CreateEventSource(source, log);
string message = (logs.Length >= maximumCharacterThatTheWindowEventLogsCanHandled
? HttpUtility.HtmlEncode(logs).Substring(0, maximumCharacterThatTheWindowEventLogsCanHandled)
: HttpUtility.HtmlEncode(logs));
EventLog.WriteEntry(source, message);
}
Labels:
c#
Windows Event Logs | Log entry string is too long. A string written to the event log cannot exceed 32766 characters
Date/Time: 05.03.2013 10:55:43
Method Name: CbtImportFromStaService.RunImportFromSta()
Error Details: Log entry string is too long. A string written to the event log cannot exceed 32766 characters.
Source: System
Stack Trace: at System.Diagnostics.EventLog.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName)
at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String source, String message)
at CBTImportFromSTA.WindowsService.Helpers.LogHelper.WriteToWindowsEventLogs(String logs)
at CBTImportFromSTA.WindowsService.Helpers.LogHelper.LogErrorsWindowsEventLogs(String exceptionContent)
at CBTImportFromSTA.WindowsService.Helpers.MailHelper.SendEmail(String exceptionContent, String optionalSubject)
at CBTImportFromSTA.WindowsService.CbtImportFromStaService.GetFirstXmlAttachmentOfEachEmail(MailMan mailman)
at CBTImportFromSTA.WindowsService.CbtImportFromStaService.FetchEmailsFrom_cbtresults_dot_import_at_osm_dot_biz_AndExtractOneXmlFileFromEachEmail()
at CBTImportFromSTA.WindowsService.CbtImportFromStaService.RunImportFromSta()
Labels:
c#
Thursday, August 9, 2012
Merak 9.4.2, CLSID {FBD995D1-EA68-4BD0-909D-461102F67E8F} problem
OS Version:Windows 7 64 bit
Visual Studio:Visual Studio 2010
Language:C#
Component:Merak 9.4.2
Problem:
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {FBD995D1-EA68-4BD0-909D-461102F67E8F}
Resolution:
Compile using x86, that solved my problem for the past 3 days =)
Visual Studio:Visual Studio 2010
Language:C#
Component:Merak 9.4.2
Problem:
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {FBD995D1-EA68-4BD0-909D-461102F67E8F}
Resolution:
Compile using x86, that solved my problem for the past 3 days =)
Wednesday, October 26, 2011
LINQ to Entities does not recognize the method 'System.DateTime AddHours(Double)'
Problem:
LINQ to Entities does not recognize the method 'System.DateTime AddHours(Double)'
Old Code:
DateTime cutOffDateTime = DateTime.Now.AddHours(-updatedWithInNumberOfHours);
Solution:
DateTime cutOffDateTime = DateTime.Now.Subtract(new TimeSpan(0, updatedWithInNumberOfHours, 0, 0));
LINQ to Entities does not recognize the method 'System.DateTime AddHours(Double)'
Old Code:
DateTime cutOffDateTime = DateTime.Now.AddHours(-updatedWithInNumberOfHours);
Solution:
DateTime cutOffDateTime = DateTime.Now.Subtract(new TimeSpan(0, updatedWithInNumberOfHours, 0, 0));
Monday, April 26, 2010
c# | asp.net | DataBinder.Eval DataFormatString
Short date pattern. Format : {0:d}
More on => BoundField::DataFormatString Property
<asp:TemplateField HeaderText="Position Inclusive Dates" HeaderStyle-Width="75px" SortExpression="">
<ItemTemplate>
<asp:Label ID="_lblPositionIncDate" width="75px" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.PositionIncDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="_tbPositionIncDate" width="75px" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.PositionIncDate") %>'></asp:TextBox>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateField>
More on => BoundField::DataFormatString Property
Subscribe to:
Posts (Atom)