WebService: Request format is unrecognized for URL unexpectedly ending in /myMethodName
When consuming a WebService using VBScript in an HTML file, I got the following error:
Request format is unrecognized for URL unexpectedly ending in /myMethodName
Add the following to the web.config of the WebService Virtual Directory since GET and POST are disabled by default in ASP.NET 2.0 and greater:
<configuration> <system.web> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> </system.web> </configuration> Also see: http://support.microsoft.com/default.aspx?scid=kb;en-us;819267 or http://aspadvice.com/blogs/ssmith/archive/2007/09/04/FIX-Request-format-is-unrecognized-for-URL-unexpectedly-ending-in.aspx
Windows Server 2003 Hangs after Installing Windows Update
One of our customers had a Windows 2003 Server, that once the April 2011 Windows Updates were installed, after rebooting, it would take almost 2 hours to log into the console. Also, some of the service could not be started, stopped or changed. We could also not RDP into the server, but we could still connect the the SQL Server 2000 databases and the file shares were still accessible. Since this server was approaching 4 years, the customer decided to go ahead and replace the server.
The new Dell Server arrived and we also upgraded their SQL 2000 to SQL Server 2008 R2. We wanted to have the name of the new server to be the name of the old server, so we first renamed the old server, then we rebooted to apply the change. Surprisingly, after we gave the old server a new name, it booted right up like normal and let us log into the console as normal without the previous 2 hour delay. All of the services started normally and we could now RDP into the server.
Now we did not rename the old server back to the original name to see if the hang at login would still occur, but my guess is that it would not hang and that it would log in normally.
UPDATE: We had this happen again on a different Win2003 Server. We disconnected the network cable, logged into the server. Renamed the server and rebooted. Booted normally and was able to log into the server. Renamed the server back to the original name and rebooted. Server now boots normally and does not hang.
Something must getting reset or rebound when you change the name of a server to make this issue get resolved.
Hope that this information may help you if you find yourself stuck in this situation.
XML Serialization
Private Function LoadInvoice(XMLFilename As String) As Boolean Try Dim reader As TextReader = New StreamReader(XMLFilename) Dim serializer As New XmlSerializer(GetType(Invoice.Documents)) Dim myInvoices As New Invoice.Documents myInvoices = DirectCast(serializer.Deserialize(reader), Invoice.Documents) reader.Close() Dim xmlOutputFilename As String = Path.GetDirectoryName(XMLFilename) xmlOutputFilename &= "\" & Path.GetFileNameWithoutExtension(XMLFilename) & "_1.xml" Dim writer As FileStream = New FileStream(xmlOutputFilename, FileMode.Create) serializer = New XmlSerializer(GetType(Invoice.Documents)) serializer.Serialize(writer, myInvoices) writer.Close() Catch ex As Exception Log.TraceError(ex, String.Format("Error occured in {0}", System.Reflection.MethodInfo.GetCurrentMethod.Name)) End Try End Function
Error: Failed to create component ‘AxHost’
When adding an ActiveX control onto a Visual Studio 2008 or 2010 Form, you get an error message stating Failed to create component ‘AxHost’, followed by some other text. This is caused any existing AxInterop.????.dll and Interop.?????.dll file that may already existing in the Project\obj\Debug folder. This is not to be confused with the Project\bin\Debug directory.
To correct, remove any Project level reference, then delete the 2 dll files. Then you can add the ActiveX control to the Form without any error.
DataTable.DefaultView Property – Gets a customized View of the Table that may include a Filtered View, or a Cursor position.
Gets a customized view of the table that may include a filtered view, or a cursor position.
The DefaultView property returns a DataView you can use to sort, filter, and search a DataTable.
The following example sets a property of the DataTable object’s DataView through the DefaultView property. The example also shows the binding of a DataGridView control to a DataTable named “Suppliers” that includes a column named “CompanyName.”
Private Sub BindDataGrid() Dim table As New DataTable ' Insert code to populate a DataTable with data. ' Bind DataGrid to DataTable DataGrid1.DataSource = table End Sub Private Sub ChangeRowFilter() Dim gridTable As DataTable = _ CType(dataGrid1.DataSource, DataTable) ' Set the RowFilter to display a company names ' that begin with A through I. gridTable.DefaultView.RowFilter = "CompanyName < 'I'" End Sub
Dynamicaly create XML Elements in XML Literals
XML Literals
d is a Class that has a Fuction named GetXMLFilenames defined.
GetXMLFilenames returns a List(Of XElements).
Dim _XMLDoc = <OBJECT> <OBJTYPE>0</OBJTYPE> <PAGES><%= d.PageCount %></PAGES> <%= From elem In d.GetXMLFilenames Select New XElement(elem.Name, elem.Value) %> </OBJECT> Public Function GetXMLFilenames() As List(Of XElement) Try Dim tempstr As String = "" Dim _XElementList As New List(Of XElement) Dim _i As Integer = 0 For Each _Filename In _Filenames _i += 1 Dim _XElement As New XElement("FILE" & _i, _Filename) _XElementList.Add(_XElement) Next Return _XElementList Catch ex As Exception Throw ex End Try End Function
Like Operator
Compares a string against a pattern.
Copy
result = string Like pattern
Parts
result
Required. Any Boolean variable. The result is a Boolean value indicating whether or not the string satisfies the pattern.
string
Required. Any String expression.
pattern
Required. Any String expression conforming to the pattern-matching conventions described in “Remarks.”
Remarks
If the value in string satisfies the pattern contained in pattern, result is True. If the string does not satisfy the pattern, result is False. If both string and pattern are empty strings, the result is True.
Comparison Method
The behavior of the Like operator depends on the Option Compare Statement. The default string comparison method for each source file is Option Compare Binary.
Pattern Options
Built-in pattern matching provides a versatile tool for string comparisons. The pattern-matching features allow you to match each character in string against a specific character, a wildcard character, a character list, or a character range. The following table shows the characters allowed in pattern and what they match.
Characters in pattern
Matches in string
?
Any single character
*
Zero or more characters
#
Any single digit (0–9)
[ charlist ]
Any single character in charlist
[! charlist ]
Any single character not in charlist
Character Lists
A group of one or more characters (charlist) enclosed in brackets ([ ]) can be used to match any single character in string and can include almost any character code, including digits.
An exclamation point (!) at the beginning of charlist means that a match is made if any character except the characters in charlist is found in string. When used outside brackets, the exclamation point matches itself.
Special Characters
To match the special characters left bracket ([), question mark (?), number sign (#), and asterisk (*), enclose them in brackets. The right bracket (]) cannot be used within a group to match itself, but it can be used outside a group as an individual character.
The character sequence [] is considered a zero-length string (“”). However, it cannot be part of a character list enclosed in brackets. If you want to check whether a position in string contains one of a group of characters or no character at all, you can use Like twice. For an example, see How to: Match a String against a Pattern (Visual Basic).
Character Ranges
By using a hyphen (–) to separate the lower and upper bounds of the range, charlist can specify a range of characters. For example, [A–Z] results in a match if the corresponding character position in string contains any character within the range A–Z, and [!H–L] results in a match if the corresponding character position contains any character outside the range H–L.
When you specify a range of characters, they must appear in ascending sort order, that is, from lowest to highest. Thus, [A–Z] is a valid pattern, but [Z–A] is not.
Multiple Character Ranges
To specify multiple ranges for the same character position, put them within the same brackets without delimiters. For example, [A–CX–Z] results in a match if the corresponding character position in string contains any character within either the range A–C or the range X–Z.
Usage of the Hyphen
A hyphen (–) can appear either at the beginning (after an exclamation point, if any) or at the end of charlist to match itself. In any other location, the hyphen identifies a range of characters delimited by the characters on either side of the hyphen.
Collating Sequence
The meaning of a specified range depends on the character ordering at run time, as determined by Option Compare and the locale setting of the system the code is running on. With Option Compare Binary, the range [A–E] matches A, B, C, D, and E. With Option Compare Text, [A–E] matches A, a, À, à, B, b, C, c, D, d, E, and e. The range does not match Ê or ê because accented characters collate after unaccented characters in the sort order.
Digraph Characters
In some languages, there are alphabetic characters that represent two separate characters. For example, several languages use the character æ to represent the characters a and e when they appear together. The Like operator recognizes that the single digraph character and the two individual characters are equivalent.
When a language that uses a digraph character is specified in the system locale settings, an occurrence of the single digraph character in either pattern or string matches the equivalent two-character sequence in the other string. Similarly, a digraph character in pattern enclosed in brackets (by itself, in a list, or in a range) matches the equivalent two-character sequence in string.
Overloading
The Like operator can be overloaded, which means that a class or structure can redefine its behavior when an operand has the type of that class or structure. If your code uses this operator on such a class or structure, be sure you understand its redefined behavior. For more information, see Operator Procedures (Visual Basic).
Example: This example uses the Like operator to compare strings to various patterns. The results go into a Boolean variable indicating whether each string satisfies the pattern.
Visual Basic
Dim testCheck As Boolean ' The following statement returns True (does "F" satisfy "F"?) testCheck = "F" Like "F" ' The following statement returns False for Option Compare Binary ' and True for Option Compare Text (does "F" satisfy "f"?) testCheck = "F" Like "f" ' The following statement returns False (does "F" satisfy "FFF"?) testCheck = "F" Like "FFF" ' The following statement returns True (does "aBBBa" have an "a" at the ' beginning, an "a" at the end, and any number of characters in ' between?) testCheck = "aBBBa" Like "a*a" ' The following statement returns True (does "F" occur in the set of ' characters from "A" through "Z"?) testCheck = "F" Like "[A-Z]" ' The following statement returns False (does "F" NOT occur in the ' set of characters from "A" through "Z"?) testCheck = "F" Like "[!A-Z]" ' The following statement returns True (does "a2a" begin and end with ' an "a" and have any single-digit number in between?) testCheck = "a2a" Like "a#a" ' The following statement returns True (does "aM5b" begin with an "a", ' followed by any character from the set "L" through "P", followed ' by any single-digit number, and end with any character NOT in ' the character set "c" through "e"?) testCheck = "aM5b" Like "a[L-P]#[!c-e]" ' The following statement returns True (does "BAT123khg" begin with a ' "B", followed by any single character, followed by a "T", and end ' with zero or more characters of any type?) testCheck = "BAT123khg" Like "B?T*" ' The following statement returns False (does "CAT123khg"?) begin with ' a "B", followed by any single character, followed by a "T", and ' end with zero or more characters of any type?) testCheck = "CAT123khg" Like "B?T*"
Retrieve Class Properties
Get all of the Properties for a Class call Invoices
Private Function GetInvoiceProperties() as Boolean ' List the properties. Dim property_value As Object Dim properties_info As PropertyInfo() = Invoices(0).[GetType]().GetProperties() lvwProperties.BeginUpdate() lvwProperties.Items.Clear() For i As Integer = 0 To properties_info.Length - 1 With properties_info(i) If .GetIndexParameters().Length = 0 Then property_value = .GetValue(Invoices(RecordNumber - 1), Nothing) If property_value Is Nothing Then ListViewMakeRow(lvwProperties, .Name, "<Nothing>") Else ListViewMakeRow(lvwProperties, .Name, property_value.ToString) End If Else ListViewMakeRow(lvwProperties, .Name, "<array>") End If End With Next i End Function Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal item_title As String, ByVal ParamArray subitem_titles() As String) Try ' Make the item. Dim new_item As ListViewItem = lvw.Items.Add(item_title) ' Make the sub-items. For i As Integer = subitem_titles.GetLowerBound(0) To subitem_titles.GetUpperBound(0) new_item.SubItems.Add(subitem_titles(i)) Next i Catch ex As Exception End Try End Sub
Format DataGridView Cells
Need to format a DataGrid Cell?
Private Sub grdDataSchema_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles grdDataSchema.CellFormatting Try If e.ColumnIndex = 1 Then If (e.Value.ToString.Contains("H")) Then e.CellStyle.BackColor = Color.Red e.CellStyle.ForeColor = Color.White End If End If Catch ex As Exception Throw ex End Try End Sub
Convert Office Documents to PDF
Need to convert an Office Document to PDF using the ABCpdf SDK by WebSuperGoo.
Dim theDoc As Doc = New Doc() Dim xr As XReadOptions = New XReadOptions() xr.ReadModule = ReadModuleType.XpsAny theDoc.Read("C:\Office\MySpreadsheet.xls", xr) theDoc.Save("C:\Office\MySpreadsheet.xls.pdf")