List of exceptions that CAN’T be caught in .NET

The only exception that cannot be caught directly is (a framework thrown) StackOverflowException. This makes sense, logically, as you don’t have the space in the stack to handle the exception at that point. From the docs: Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the … Read more

As of today, what is the right way to work with COM objects? [duplicate]

The .NET / COM interop is well designed, and works correctly. In particular, the .NET Garbage Collector correctly tracks COM references, and will correctly release COM objects when they have no remaining runtime references. Interfering with the reference counts of COM object by calling Marshal.ReleaseComObject(…) or Marshal.FinalReleaseComObject(…) is a dangerous but common anti-pattern. Unfortunately, some … Read more

Display varbinary Image in Gridview

The following will show how to retrieve an image from SQL Server and display it in a GridView on an ASP.NET web page. Create a table in the database: CREATE TABLE Surplus([Surplus Id] int not null, Department nchar(50), Category nchar(25), Item nchar(75), Visible bit, TransferableImage varbinary(max), CONSTRAINT PK_Surplus_SurplusId PRIMARY KEY([Surplus Id])); Note: If a table … Read more

Help with Linq and Generics. Using GetValue inside a Query

You need to convert the code to an expression tree. using System; using System.Linq; using System.Linq.Expressions; using System.Reflection; namespace WindowsFormsApplication1 { static class Program { [STAThread] static void Main() { using (var context = new NorthwindEntities()) { IQueryable<Customer> query = context.Customers; query = Simplified<Customer>(query, “CustomerID”, “ALFKI”); var list = query.ToList(); } } static IQueryable<T> Simplified<T>(IQueryable<T> … Read more

Can you use Java libraries in a VB.net program?

No, you can’t. Unless you are willing to use some “J#” libraries (which is not nearly the same as Java) or IKVM which is a Java implementation that runs on top of .NET, but as their documentation says: IKVM.OpenJDK.ClassLibrary.dll: compiled version of the Java class libraries derived from the OpenJDK class library with some parts … Read more

How to call the Magento API from VB.NET

Function getHTTPStream() As String Dim myh As HttpWebRequest = _ HttpWebRequest.Create(“http://yourmagentoweb/soap/api/?wsdl”) myh.Timeout = 30000 myh.UserAgent = “Test” Dim myR As HttpWebResponse = myh.GetResponse() Dim myEnc As Encoding = Encoding.GetEncoding(1252) Dim mySr As StreamReader = New StreamReader(myR.GetResponseStream(), myEnc) Return mySr.ReadToEnd() End Function That code needs tweaking obviously- i have not got time to prettify this stuff … Read more