.net

MFC class's destructor is called twice from managed C++

My task is to allow a MFC based legacy code to be called from .NET applications. I thought about using Managed C++. It works quite fine untill one of the legacy MFC classes get destroyed. I could debug the run of the destructor, without any sign of error. After the destructor, but while the program lefts the scope, the application crashe...

Any way to generate compiler warning for unused usings?

Is there any way to generate a warning in VS2008 for unused using statements? I know there is the Edit->Intellisense->Organize Usings->Remove Unused Usings, but it would be nice if this were a compile time warning. ...

Detect what process/program start my process/program

Is there a way in code to detect what process or application starts my process or application. Any .net, vb6 or c++ code snips would be great ...

Windows Forms WebBrowser control and iframes

I am trying to create a piece of software to more or less automate form-fillings on a webpage - and I have decided to use the WebBrowser control in System.Windows.Forms. This works great and I can easily manipulate the DOM through webbrowser.Document and so forth. However unfortunately the site that I am doing automation on has a file up...

How to run and debug nunit tests in Visual Studio 2008 on 64-bit Windows 7?

Hello, I've exchanged my dev machine (WinXP/32bit) to a new one (Windows 7/64bit). Now I have trouble running NUnit test from inside Visual Studio 2008. I'm using latest build of TestDrivenNet. What I am looking for is either: a) how to make TestDrivenNet work on Win7/64 b) looking for suggestion for alternative test runner. Free one...

Purpose of having API wrapped around interface

I am working on a piece of C# web application that has a page (MainPage) with a small area to display a gadget. There are several kinds of gadgets implementing a main interface (IMainInterface) and an optional interface (IOptionalInterface). In MainPage, when interacting with the gadget class, it uses following syntax: MyAPI api = new ...

ASCX control not visible in design mode in VS2008

I have a custom ASCX control that is not visible in design mode in VS2008. It used to be, I changed nothing and now when I switch back to design mode, it is not visible. Has anyone ever face this situation? ...

Need of ClassInterfaceType.None?

Didn't quite get the following from MSDN: ClassInterfaceType.None Indicates that no class interface is generated for the class. If no interfaces are implemented explicitly, the class can only provide late-bound access through the IDispatch interface. This is the recommended setting for ClassInterfaceAttribute. Usi...

How can I get fields used in a method (.NET) ?

In .NET, using reflection how can I get class variables that are used in a method? Ex: class A { UltraClass B = new(..); SupaClass C = new(..); void M1() { B.xyz(); // it can be a method call int a = C.a; // a variable access } } Note: GetClassVariablesInMethod(M1 MethodInfo) returns B and C varia...

How to parse DateTime SubString out of variable String

I have a String like this: "WAIT_UNTIL;SYSTEM_TIME >= Di 15 Sep 2009 23:00:21 and IgnKeyPos ==3" or something like this "IF;Thermal >=20 and SYSTEM_TIME >= Tue 16 Sep 2009 23:00:21 " I need to extract only the Time and Date part so I can use it later like this: TimeThen = DateTime.Parse("Di 15 Sep 2009 23:00:21"); How...

Is there a way to get xsd.exe to generate classes with "internal" scope?

I've got a DLL that contains some XSD-generated classes. Unfortunately, XSD.exe makes those classes public, which results in "Missing XML comment for publicly visible type or member XYZ" warnings. Plus, I'd rather not expose those classes from my DLL. Is there a way, short of manually editing the generated .cs, to make those classes i...

How can I add endpoint behaviors to the client service with duplex contracts ?

I have created a binding which supports duplex communication, but it needs that the endpoint has the SynchonousReceiveBehavior : endpoint.Behaviors.Add(new SynchronousReceiveBehavior()); This is really easy to do on the server side. However, I need to use a duplex contract and I don't find how I can specify this behavior to the hos...

Image border manipulation in C#

I have a need to resize pictures on a website I'm making for my company. The pictures must be a very specific size, and if the proportions are not correct I must be able to pad the image with a border to make it 'fit'. I'm not sure what the best way to approach this problem is. My knee-jerk was to simply add Rectangles to the image on...

Multi-threading the formatting of datagridview rows?

I've read a number of examples on using BackgroundWorker objects to handle executing time-intensive tasks which generate results which are used to populate a DataGridView. However in my case it seems as though the act of populating the DataGridView is what's taking the most time. I'm wondering if this is because I need to format the re...

Getting Value from DataView C#

Hello, How to find a value of some column from DataView.CurrentItem. ...

Get a list of directories on a shared computer .NET

I have a list of the name of shared computers of the form "\\computer" and need to find shared folders on those machines. All of the .Net methods I've been able to find require a valid UNC to be called but since I only have the list of computers I cannot make a valid UNC. Is there a way to discover all of the shared folders on a comput...

How to split a string while ignoring the case of the delimiter?

I need to split a string let's say "asdf aA asdfget aa uoiu AA" split using "aa" ignoring the case. to "asdf " "asdfget " "uoiu " ...

Nhibernate: one-to-many, based on multiple keys?

Lets assume I have two tables Table tA ID ID2 SomeColumns Table tB ID ID2 SomeOtherColumns I am looking to create a Object let's call it ObjectA (based on tA), that will have a one-to-many relationship to ObjectB (based on tB). In my example however, I need to use the combination of ID and ID2 as the foreign key....

Jquery and ASCX control rendered multiple times on a page

I have an ascx control which contains dropdownboxes I want to be able to reset with JavaScript. Because the ascx control is rendered multiple times on the aspx page, I programatically add a distinguishing field to each dropdown such as this in the code behind of the ascx: var g = Guid.NewGuid().ToString().Replace("-", ""); DropDownListB...

Why Generic Casting is not working on this section of code?

IQueryable<T> IS3Repository.FindAllBuckets<T>() { IQueryable<object> list = _repository.GetAllBuckets().Cast<object>().AsQueryable(); return list == null ? default(T) : (T)list; } This is the error: Error 3 Cannot implicitly convert type 'T' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?) I ...