No console output when using AllocConsole and target architecture x86

When “Enable native code debugging” is enabled, output from consoles crated with AllocConsole is redirected to the debug output window instead. The reason this only happens in x86 and not AnyCPU is because you can only debug native code in an x86 application. Note that this behavior only occurs with consoles created with AllocConsole. A … Read more

Unblock File from within .net 4 c#

Based on your input I have done the following code: public class FileUnblocker { [DllImport(“kernel32”, CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool DeleteFile(string name); public bool Unblock(string fileName) { return DeleteFile(fileName + “:Zone.Identifier”); } } Thanks to Stuart Dunkeld, Alex K(+1) and Sven to show me the direction. UPDATE I … Read more

Should DWORD map to int or uint?

Well according to the MSDN DWORD is an unsigned integer with a range of 0 to 4294967295. So ideally you should replace it with uint rather than int. However, as you have spotted uint is non-CLS compliant so if your method is publicly visible you should use int and do the conversion. The corollary to … Read more

Getting Symbols from debugged process MainModule

can it be that you are looking for System.Diagnostics.SymbolStore.ISymbolScope. Have a look at the class SymbolAccess, you can use it to gain access to ISymbolScope.GetLocals() that returns ISymbolVariable[] and GetChildren() again returning in this time an array called ISymbolVariable[] Now another interesting set of reference code samples is the Debugger extension lets you “snif” the … Read more

Best way to access COM objects from C#

If the library is already registered, you can perform the following steps to have Visual Studio generate an interop assembly for you: Open to your Visual Studio project. Right click on ‘References’ (right under the project in your Solution Explorer) and select ‘Add Reference’. Select the COM tab. (If you don’t see this, you have … Read more

P/Invoke or C++/CLI for wrapping a C library

In the case where I am working with an existing C library, I prefer PInvoke. PInvoke, while a bit tedious and troublesome at times, is a fairly well understood technology that has an ever growing set of tools and internet documentation available. Generally speaking, whatever problem you run into, there is already a sample available … Read more

Working example of CreateJobObject/SetInformationJobObject pinvoke in .net?

This can be little bit late, but still. I tried all of the examples here, but no one was working for me in 32 and 64 bit mode simultaneously. Finally, I was required to examine all the signatures myself and create corresponding PInvoke routines. I think, somebody else could find this helpful. Disclaimer: the solution … Read more

tech