.net

comments compiled into .exe in .net?

I know you can use a .net reflector to view code created with .net but if i put something in the comments for my own personal reminder is that compiled in the exe as well. I don't intend to release the source code for my application and i know the 100% safe bet is to just remove everything i don't want out but i was just wondering if so...

.NET code access security - why is it hardly ever used?

.NET code access security has been around for a long time, yet it seems to hardly ever be used in the real world. To my way of thinking, this seems like an excellent concept, and one I had not seen prior to .NET. (Does it exist in other languages?) I would like to know if anyone is proactively using it in their projects and why? For t...

What sort of gotchas/tips/hints can you share for a .Net program which will send possibly 10k+ emails a day to subscribers?

I know how to write the basic c# code to send emails, but I'm wondering about any larger issues involved. Are there things I should avoid? Best practices? etc Thanks!! ...

Enterprise Library How to Implement a IExceptionHandler?

I have to implement a IExceptionHandler for the Enteprise Library 4.1. In my particular case I want to use it to log the exception to Fogbugz but the inner details is not what I am asking about. What I need is how to - best practicies - implement it, How to get the config for a app.config or web.config. etc. I have code This so far: ...

Programmatically Reading _AssemblyLocation From a VSTO Excel Workbook

I've got a Visual Studio Excel Workbook project. When I publish the workbook and examine the source of the workbook (I open WinZip and check custom.xml), I see the tag _AssemblyLocation, which corresponds to the publish path. Is there a way to read _AssemblyLocation from my .NET code? I'd like to be able to read the publish path and de...

How can I selectively validate a form in WPF?

I'm currently using the validation code listed here in an application. I'd like to selectively validate a page. What I mean by that is this: I have a form that's databound with validation rules attached. I also have a checkbox that, when checked, disables and clears the values of several bound textboxes. Is there a property I can set on ...

How do I measure elapsed time of actual HttpWebResponse versus transmission of HttpWebRequest?

I have an application that posts a large file to a vendor's API and gets a response. It does so thusly: HttpWebRequest webRequest = BuildWebRequest(..., requestParams.Data, ...); HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); I would like to measure the elapsed time of only the response itself (excluding the...

Declarative security demands - Is SecurityAction.Demand cached ??

Hi I am having a trouble during impersonating a user. I have a method declared like this: [PrincipalPermission(SecurityAction.Demand, Name=@"DJPITER-PC\Test", Role="LocalTestGroup")] static void LocalTestGroupOnly() { Console.WriteLine("Inside LocalTestGroupOnly() - {0}", WindowsIdentity.GetCurrent().Name); } The calling...

How can I convert a .Net Datetime to a T-SQL Datetime

MyDataSource.SelectParameters["startDate"].DefaultValue = fromDate.SelectedDate.Date.ToString(); As you can see I am setting the default value of a parameter in my .Net SqlDataSource. I don't think the string is outputting the correct format though. What is the correct format so a T-SQL Datetime wil...

Native C++ or .NET for Business App?

Here's the deal: I'm in the process of planning a mid-sized business application that absolutely must support Win2k. AFAIK, official .NET support for Win2k was scrapped a while ago (IIRC, it stopped at version 2.0). Now, I already wrote (ages ago) libraries in C++ that allow me to accomplish the end result (i.e., finish this project) ju...

Why can't I serialize an object using DataContractSerializer?

I'm trying to serialize a type using the DataContractSerializer and am getting the exception below. This isn't for an SOA service, but I would still like to use the DataContractSerializer if possible. I am using .Net 3.5 SP1. Type 'System.DelegateSerializationHolder+DelegateEntry' with data contract name 'DelegateSerializatio...

How will this work? (interfaces and non virtual functions)

interface I { int J(); } class A : I { public int J(){return 0; } // note NOT virtual (and I can't change this) } class B : A, I { new public int J(){return 1; } } B b = new B(); A a = b; I ib = b, ia = a; b.J(); // should give 1 a.J(); // should give 0 (IMHO) ia.J(); // ??? ib.J(); // ??? I know I could just try it but I...

C3374: can't take address of 'function' unless creating delegate instance

I am having difficulty using a thirdparty library registration function to register a callback. I am writing in C++ CLI, and accessing a library written in C or C++. What does the above compiler error mean? this is the registration function as defined by the vendor: MYCO int WINAPI MyCo_Device_Register_CallbackFunc(LPVOID func, LPVOI...

Immutability and static variables

I am designing some immutable classes but I have to have some variables like say .Count to have the total count of the instances. But would having a static variable affect multi-threading? Because methods like Add, Remove, etc have to update the .Count value. Maybe I should make it lazy property? ...

Simulate a request from a IE Client with WebClient class?

I am downloading files with the WebClient class in .NET 3.5. I would like to be sure that on the server side, the files requested appear to be downloaded with a IE client. What do I have to change exactly? Do I have simply to copy the header information generated by IE to the Header property of the WebClient object? Is there anything e...

Reducing flicker when you change images in a panel

How do i reduce flicker in a vb2005 panel? Inside the parent panel i have 2 other panels that im am using. The outer most panel contains a background sprite and the two innermost panels are overlays that change to fit the places in the background sprite. When i change the overlay sprites i would like to reduce the flicker and make it a...

.NET Regex fails to match in code, works in every testing harness

This one is a real head scratcher for me... var matches = Regex.Matches("<p>test something<script language=\"javascript\">alert('hello');</script> and here's <b>bold</b> and <i>italic</i> and <a href=\"http://popw.com/\"&gt;link&lt;/a&gt;.&lt;/p&gt;", "</?(?!p|a|b|i)\b[^>]*>"); The Regex is supposed to capture any HTML tag (open or cl...

How can I make a Visual Studio Macro to attach the debugger to all instances of w3wp.exe?

I'm normally developing web apps, and a surprisingly large amount of my work time is spent doing "Ctrl + Alt + P", sorting by Process Name, and picking w3wp.exe to attach my debugger. To make matters worse, I'm working on an app that spans several application pools, so I normally have 2 or 3 instances of w3wp.exe, and it's impossible to...

How do you determine the last process to modify a file?

I know how to get the user that last modified a file, but does Windows track the process that made the modification as well? If so, is there an API for looking that up? ...

Best way to document WCF interface?

So I'm using WCF, and want to document my interface(s) and services to give to another company for an internal app. What's the best way to document those interfaces? I'd prefer having the documentation inline with the code, and then have something prettify to output HTML, but am not sure if there's a recommended way to do it. Thanks....