.net

Anyone with Postsharp experience in production?

Does anyone out there has used Postsharp AOP framework in production environment? Are there any pitfalls? In order to do some logging etc, can Postsharp be used in conjunction with log4net ? Any tutorials on using Postsharp with Web Apps and/or log4net will be highly appreciated. Thanks In Advance. ...

.NET: Which Exception to Throw When a Required Configuration Setting is Missing?

Here's a standard scenario: if(string.IsNullOrEmpty(Configuration.AppSettings("foobar"))) throw new SomeStandardException("Application not configured correctly, bozo."); The problem is, I am not entirely certain which exception SomeStandardException should be. I perused the 3.5 Framework and found two likely candidates: Configura...

.NET Attributes: Why does GetCustomAttributes() make a new attribute instance every time?

So I was playing around a little more with attributes in .NET, and realized that every call to Type.GetCustomAttributes() creates a new instance of my attribute. Why is that? I would think that the attribute instance would basically be a singleton-per-MemberInfo, with 1 instance bound to the Type, PropertyInfo, etc... Here is my test co...

Why Create Custom Exceptions?

Why do we need to create custom exceptions in .NET? ...

How Do I Track and Eliminate Session Abuse?

I'm pretty sure that there have been developers in the past that have severely abused our poor friend ASP.NET session state. Session would love to help track things between requests, but can only do so much! Please help me ease its pain so that it can work with us happily ever after. Does anyone know of a tool that can monitor session...

.NET web service without proxy class

I'm trying to create an application that will let me execute a method specified at runtime on an arbitrary webservice (the URL of which I'll also provide at runtime). I've figured out how to use Type.InvokeMember to execute the arbitrary method, but how do I specify the web service to consume without creating a proxy class. I found htt...

Float vs Double Performance

I did some timing tests and also read some articles like this one (last comment),and it looks like in Release build, float and double values take the same amount of processing time. How is this possible? When float is less precise and smaller compared to double values, how can the CLR get doubles into the same processing time? Edit: ...

Are there any good workarounds for FxCop warning CA1006?

I am having trouble with FxCop warning CA1006, Microsoft.Design "DoNotNestGenericTypesInMemberSignatures". Specifically, I am designing a ReportCollection<T> class that inherits from ReadOnlyCollection<Report<T>>, and its public constructor takes an IList<Report<T>> as a parameter. The suggestion for fixing this warning is not very usef...

getting 'System.OutOfMemoryException' when converting byte array to string

code snippet: //byte[] myByteArray = byte array from database (database BLOB) myByteArray = (byte[]) ((dbCommand.Parameters["parameter"].Value)); string myString =System.Text.Encoding.UTF8.GetString(myByteArray); Xmldocument doc = new Xmldocument(); doc.Load(myString); ============ I am getting System.OutOfMemoryException sometime...

How to embed .tlb as a resource file into .NET Assembly DLL?

We're using our .NET Assembly DLL within native C++ through COM (CCW). Whenever I make new version of my DLL, I have to send two files (.dll and corresponding .tlb) to crew that's using it in their code. Is it possible to embed .tlb file as a resource in .NET DLL file? ...

Need an exercise suggestions to help me learn and exercise .NET

Do you have any idea for a complex exercise that touches and covers most important and major concepts of .NET? (so I can learn while coding and implementation) The exercise should NOT be for beginners, but for someone who already familiar with .net, but enough complex to teach new features of .NET 2 for example. Thanks! ...

What is the best way of randomly re-arranging a list of items in c# ?

I have a list of objects and I want to reorder them randomly on each request. What is the best way of doing this? ...

InternalsVisibleTo not working for Managed C++

InternalsVisibleTo is not working for my managed C++ projects, but it is for my C# projects. Any help would be appreciated. Here is a simplified layout. Project A - C#, has an internal property I want to access from B/C. Project B - Managed C++. References A. Project C - C#, references A. All projects are signed with the same key. Lo...

Why do I need Stored Procedures when I have LINQ to SQL

My understanding of Linq to Sql is it will take my Linq statement and convert it into an equivalent SQL statement. So var products = from p in db.Products where p.Category.CategoryName == "Beverages" select p Just turns into Select * from Products where CategoryName = 'Beverages' If that's the case, ...

Visual Studio - rewrite / lifespan

FYI - I am a mainframer that moved to the .NET world a couple years ago and has a lot to learn. We are looking at rewriting a Visual FoxPro app into .Net (most likely VB). This project is projected at 4-6 years. We are at the very early stages of the preliminary design right now. I am seeing a LOT of information from Microsoft on VS 2...

How to use LINQ to return substring of FileInfo.Name

I would like to convert the below "foreach" statement to a LINQ query that returns a substring of the file name into a list: IList<string> fileNameSubstringValues = new List<string>(); //Find all assemblies with mapping files. ICollection<FileInfo> files = codeToGetFileListGoesHere; //Parse the file n...

Implementing IInternetZoneManager in .NET

I'm trying to implement IInternetZoneManager in .NET with Webbrowser Control but I have no clue what to do. I couldn't find any managed code example about this implementation. I'm pretty bad about OLE stuff. Can anyone provide a sample on this? I spend about 2 days with no luck. ...

Deploy compact framework without restart

When you use visual studio to deploy to a windows mobile device it automatically picks the correct cab file and installs the compact framework onto that device. All without requiring a restart. If you pick the same cab file and install it using active sync once the install is completed you are required to restart the device. Why? And h...

Threading.Timer vs. Forms.Timer

The short form of this question: When, if ever, is it appropriate to use the Forms.Timer in a multithreaded WinForms application? More specifically, I am architecting an application that uses multiple System.Threading.Timers to launch processes asynchronously, check queues containing the results of those asynchronous processes, and upda...

Java and .net for PHP programmer

Hey! I have been programming with php for a few years. I do like php and hope to keep working with it for a few more years, but I see that my company is going into the java world. Can anyone recommend any good books, tutorials, podcast´s, whatever that will help me learn java? Something basic and intermediate would be nice. Also if ther...