Search Results

Search found 505 results on 21 pages for 'intptr'.

Page 7/21 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Disabling redraw in WinForms app

    - by Ryan
    I'm working on a C#.Net application which has a somewhat annoying bug in it. The main window has a number of tabs, each of which has a grid on it. When switching from one tab to another, or selecting a different row in a grid, it does some background processing, and during this the menu flickers as it's redrawn (File, Help, etc menu items as well as window icon and title). I tried disabling the redraw on the window while switching tabs/rows (WM_SETREDRAW message) at first. In one case, it works perfectly. In the other, it solves the immediate bug (title/menu flicker), but between disabling the redraw and enabling it again, the window is "transparent" to mouse clicks - there's a small window (<1 sec) in which I can click and it will, say, highlight an icon on my desktop, as if the app wasn't there at all. If I have something else running in the background (Firefox, say) it will actually get focus when clicked (and draw part of the browser, say the address bar.) Here's code I added. m = new Message(); m.HWnd = System.Windows.Forms.Application.OpenForms[0].Handle; //top level m.WParam = (IntPtr)0; //disable redraw m.LParam = (IntPtr)0; //unused m.Msg = 11; //wm_setredraw WndProc(ref m); <snip - Application ignores clicks while in this section (in one case) m = new Message(); m.HWnd = System.Windows.Forms.Application.OpenForms[0].Handle; //top level m.WParam = (IntPtr)1; //enable m.LParam = (IntPtr)0; //unused m.Msg = 11; //wm_setredraw WndProc(ref m); System.Windows.Forms.Application.OpenForms[0].Refresh(); Does anyone know if a) there's a way to fix the transparent-application problem here, or b) if I'm doing it wrong in the first place and this should be fixed some other way?

    Read the article

  • Sendkeys problem from .NET program

    - by user203123
    THe code below I copied from MSDN with a bit of modification: [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); DllImport("User32")] public static extern bool SetForegroundWindow(IntPtr hWnd); int cnt = 0; private void button1_Click(object sender, EventArgs e) { IntPtr calculatorHandle = FindWindow("Notepad", "Untitled - Notepad"); if (calculatorHandle == IntPtr.Zero) { MessageBox.Show("Calculator is not running."); return; } SetForegroundWindow(calculatorHandle); SendKeys.SendWait(cnt.ToString()); SendKeys.SendWait("{ENTER}"); cnt++; SendKeys.Flush(); System.Threading.Thread.Sleep(1000); } The problem is the number sequence in Notepad is not continuously. The first click always results 0 (as expected). but from the second click, the result is unpredictable (but the sequence is still in order, e.g. 3, 4, 5, 10, 14, 15, ....) If I click the button fast enough, I was able to get the result in continuous order (0,1,2,3,4,....) but sometimes it produces more than 2 same numbers (e.g. 0,1,2,3,3,3,4,5,6,6,6,7,8,9,...)

    Read the article

  • Help to resolve 'Out of memory' exception when calling DrawImage

    - by Jack Juiceson
    Hi guys, About one percent of our users experience sudden crash while using our application. The logs show below exception, the only thing in common that I've seen so far is that, they all have XP SP3. Thanks in advance Out of memory. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr) at System.Windows.Forms.ControlPaint.DrawBackgroundImage(Graphics g, Image backgroundImage, Color backColor, ImageLayout backgroundImageLayout, Rectangle bounds, Rectangle clipRect, Point scrollOffset, RightToLeft rightToLeft) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle) at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent) at System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e) at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle) at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent) at System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e) at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle) at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Operation System Information ---------------------------- Name = Windows XP Edition = Home Service Pack = Service Pack 3 Version = 5.1.2600.196608 Bits = 32

    Read the article

  • Receiving an object in a unmanaged callback function

    - by Daniel Baulig
    Eg. I have following delegate method I want to use as a callback function with unmanaged code: public delegate void Callback(IntPtr myObject); Callback callback; I register it in the following way: [DllImport("a.dll")] public static void registerCallback(IntPtr callbackFunction, IntPtr anObject); // ... this.myObject = new MyClass(); this.objectPin = GCHandle.Alloc(this.myObject, GCHandleType.Pinned); registerCallback(Marshal.GetFunctionPointerForDelegate(callback), objectPin.AddrOfPinnedObject()); Now whenever the callback function is called it will have a Pointer/Handle of an object of the MyClass class. I could use Marshal.PtrToStructure to convert this to an object of MyClass. However, what I would like to have is that the delegate definition already contains the class MyClass. eg.: public delegate void Callback(MyClass myObject); I tried this, but it will not work. I also tried the following, which did not work: public delegate void Callback([MarshalAs(UnmanagedType.IUnknown)]MyClass myObject); I suppose I would need something like "UnmarshalAs" at this point, but sadly this is not available. Any suggestions how I could get lost of that IntPtr in my callback function and get a it packed up as a regular, managed MyClass object?

    Read the article

  • Question about creating device-compatible bitmaps in C#

    - by MusiGenesis
    I am storing bitmap-like data in a two-dimensional int array. To convert this array into a GDI-compatible bitmap (for use with BitBlt), I am using this function: public IntPtr GetGDIBitmap(int[,] data) { int w = data.GetLength(0); int h = data.GetLength(1); IntPtr ret = IntPtr.Zero; using (Bitmap bmp = new Bitmap(w, h)) { for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { Color color = Color.FromArgb(data[x, y]); bmp.SetPixel(x, y, color); } } ret = bmp.GetHbitmap(); } return ret; } This works as expected, but the call to bmp.GetHbitmap() has to allocate memory for the returned bitmap. I'd like to modify this method in two (probably related) ways: I'd like to remove the intermediate Bitmap from the above code entirely, and go directly from my int[,] array to the device-compatible bitmap (i.e. the IntPtr). I presume this would involve calling CreateCompatibleBitmap, but I don't know how to go from that call to actually manipulating the pixel values. This should logically follow from the answer to the first, but I'd also like my method to re-use existing GDI bitmap handles (instead of creating a new bitmap each time). How can I do this? NOTE: I don't really use Bitmap.SetPixel(), as its performance could best be described as "glacial". The code is just for illustration.

    Read the article

  • Capturing window image in windows server 2008

    - by Sergey Osypchuk
    I am capturing output of windows program using following function: public static Bitmap Get(IntPtr hWnd, int X1, int Y1, int width, int height) { WINDOWINFO winInfo = new WINDOWINFO(); bool ret = GetWindowInfo(hWnd, ref winInfo); if (!ret) { return null; } int curheight = height; if (curheight <= 0 || curheight > winInfo.rcWindow.Height) curheight = winInfo.rcWindow.Height; int curwidth = width; if (curwidth <= 0 || curwidth > winInfo.rcWindow.Width) curwidth = winInfo.rcWindow.Width; if (curheight == 0 || curwidth == 0) return null; Graphics frmGraphics = Graphics.FromHwnd(hWnd); IntPtr hDC = GetWindowDC(hWnd); //gets the entire window //IntPtr hDC = frmGraphics.GetHdc(); -- gets the client area, no menu bars, etc.. System.Drawing.Bitmap tmpBitmap = new System.Drawing.Bitmap(curwidth, curheight, frmGraphics); Graphics bmGraphics = Graphics.FromImage(tmpBitmap); IntPtr bmHdc = bmGraphics.GetHdc(); BitBlt(bmHdc, 0, 0, curwidth, curheight, hDC, X1, Y1, TernaryRasterOperations.SRCCOPY); bmGraphics.ReleaseHdc(bmHdc); ReleaseDC(hWnd, hDC); return tmpBitmap; } On Development environment everything is excellent, but on windows server 2008 I have following issues: 1) When there is other window in front my - it is getting captured as well 2) When there is no user connected to RDC - image is black On other hand, I am able to render webpage images using IE. How I can change behaviour of windows rendering process to get proper results?

    Read the article

  • how to make the printer window appear using vb.net 2010

    - by Jeline Esase
    hi I have this code that will send my panel into a printer but the problem is it doesent let me choose which printer I will use any idea on how can I make the printer window appear? thanks Public Class Form1 Dim img As Bitmap Dim WithEvents pd As PrintDocument 'Returns the Form as a bitmap Function CaptureForm1() As Bitmap Dim g1 As Graphics = Me.CreateGraphics() Dim MyImage = New Bitmap(Me.ClientRectangle.Width, (Me.ClientRectangle.Height), g1) Dim g2 As Graphics = Graphics.FromImage(MyImage) Dim dc1 As IntPtr = g1.GetHdc() Dim dc2 As IntPtr = g2.GetHdc() BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), dc1, 0, 0, 13369376) g1.ReleaseHdc(dc1) g2.ReleaseHdc(dc2) 'saves image to c drive just, u can comment it also 'MyImage.Save("c:\abc.bmp") Return MyImage End Function <DllImport("gdi32.DLL", EntryPoint:="BitBlt", _ SetLastError:=True, CharSet:=CharSet.Unicode, _ ExactSpelling:=True, _ CallingConvention:=CallingConvention.StdCall)> _ Private Shared Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Boolean ' Leave function empty - DLLImport attribute forwards calls to MoveFile to ' MoveFileW in KERNEL32.DLL. End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click img = CaptureForm1() pd = New PrintDocument pd.Print() End Sub 'this method will be called each time when pd.printpage event occurs Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles pd.PrintPage Dim x As Integer = e.MarginBounds.X Dim y As Integer = e.MarginBounds.Y e.Graphics.DrawImage(img, x, y) e.HasMorePages = False End Sub End Class

    Read the article

  • How to handle Win+Shift+LEft/Right on Win7 with custom WM_GETMINMAXINFO logic?

    - by Steven Robbins
    I have a custom windows implementation in a WPF app that hooks WM_GETMINMAXINFO as follows: private void MaximiseWithTaskbar(System.IntPtr hwnd, System.IntPtr lParam) { MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO)); System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); if (monitor != System.IntPtr.Zero) { MONITORINFO monitorInfo = new MONITORINFO(); GetMonitorInfo(monitor, monitorInfo); RECT rcWorkArea = monitorInfo.rcWork; RECT rcMonitorArea = monitorInfo.rcMonitor; mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left); mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top); mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left); mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top); mmi.ptMinTrackSize.x = Convert.ToInt16(this.MinWidth * (desktopDpiX / 96)); mmi.ptMinTrackSize.y = Convert.ToInt16(this.MinHeight * (desktopDpiY / 96)); } Marshal.StructureToPtr(mmi, lParam, true); } It all works a treat and it allows me to have a borderless window maximized without having it sit on to of the task bar, which is great, but it really doesn't like being moved between monitors with the new Win7 keyboard shortcuts. Whenever the app is moved with Win+Shift+Left/Right the WM_GETMINMAXINFO message is received, as I'd expect, but MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST) returns the monitor the application has just been moved FROM, rather than the monitor it is moving TO, so if the monitors are of differing resolutions the window end up the wrong size. I'm not sure if there's something else I can call, other then MonitorFromWindow, or whether there's a "moving monitors" message I can hook prior to WM_GETMINMAXINFO. I'm assuming there is a way to do it because "normal" windows work just fine.

    Read the article

  • How do I handle freeing unmanaged structures on application close?

    - by LostKaleb
    I have a C# project in which i use several unmanaged C++ functions. More so, I also have static IntPtr that I use as parameters for those functions. I know that whenever I use them, I should implement IDisposable in that class and use a destructor to invoke the Dispose method, where I free the used IntPtr, as is said in the MSDN page. public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { if (disposing) { component.Dispose(); } CloseHandle(m_InstanceHandle); m_InstanceHandle = IntPtr.Zero; disposed = true; } } [System.Runtime.InteropServices.DllImport("Kernel32")] private extern static Boolean CloseHandle(IntPtr handle); However, when I terminate the application, I'm still left with a hanging process in TaskManager. I believe that it must be related to the used of the MarshalAs instruction in my structures: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SipxAudioCodec { [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string CodecName; public SipxAudioBandwidth Bandwidth; public int PayloadType; } When I create such a structure should I also be careful to free the space it allocs using a destructor? [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SipxAudioCodec { [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string CodecName; public SipxAudioBandwidth Bandwidth; public int PayloadType; ~SipxAudioCodec() { Marshal.FreeGlobal(something...); } }

    Read the article

  • Maximize/Minimize is causing Close Button to be re-enabled after disabling it -- Why?

    - by Brainsick
    I have used P/Invoke to call GetSystemMenu and EnableMenuItem (win32api) to disable the close functionality. However, after minimizing or maximizing my Windows Forms application the button is re-enabled. Obviously minimizing or maximizing is causing the behavior, but how? I'm not sure where to look to prevent this behavior. Should I be preventing the maximize and minimize behavior or is there something particularly wrong with the way in which I P/Invoked the calls? Once the application (main form) has loaded, I call the static method from a button click. class PInvoke { // P/Invoke signatures [DllImport("user32.dll")] static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable); // SysCommand (WM_SYSCOMMAND) constant internal const UInt32 SC_CLOSE = 0xF060; // Constants used with Add/Check/EnableMenuItem internal const UInt32 MF_BYCOMMAND = 0x00000000; internal const UInt32 MF_ENABLED = 0x00000000; internal const UInt32 MF_GRAYED = 0x00000001; internal const UInt32 MF_DISABLED = 0x00000002; /// <summary> /// Sets the state of the Close (X) button and the System Menu close functionality. /// </summary> /// <param name="window">Window or Form</param> /// <param name="bEnabled">Enabled state</param> public static void EnableCloseButton(IWin32Window window, bool bEnabled) { IntPtr hSystemMenu = GetSystemMenu(window.Handle, false); EnableMenuItem(hSystemMenu, SC_CLOSE, MF_BYCOMMAND | (bEnabled ? MF_ENABLED : MF_GRAYED)); } }

    Read the article

  • How do I handle freeing unmanaged structures in C# on application close?

    - by LostKaleb
    I have a C# project in which i use several unmanaged C++ functions. More so, I also have static IntPtr that I use as parameters for those functions. I know that whenever I use them, I should implement IDisposable in that class and use a destructor to invoke the Dispose method, where I free the used IntPtr, as is said in the MSDN page. public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { if (disposing) { component.Dispose(); } CloseHandle(m_InstanceHandle); m_InstanceHandle = IntPtr.Zero; disposed = true; } } [System.Runtime.InteropServices.DllImport("Kernel32")] private extern static Boolean CloseHandle(IntPtr handle); However, when I terminate the application, I'm still left with a hanging process in TaskManager. I believe that it must be related to the used of the MarshalAs instruction in my structures: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SipxAudioCodec { [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string CodecName; public SipxAudioBandwidth Bandwidth; public int PayloadType; } When I create such a structure should I also be careful to free the space it allocs using a destructor? [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct SipxAudioCodec { [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string CodecName; public SipxAudioBandwidth Bandwidth; public int PayloadType; ~SipxAudioCodec() { Marshal.FreeGlobal(something...); } } Thanks in advance!

    Read the article

  • Minecraft Style Chunk building problem

    - by David Torrey
    I'm having some problems with speed in my chunk engine. I timed it out, and in its current state it takes a total ~5 seconds per chunk to fill each face's list. I have a check to see if each face of a block is visible and if it is not visible, it skips it and moves on. I'm using a dictionary (unordered map) because it makes sense memorywise to just not have an entry if there is no block. I've tracked my problem down to testing if there is an entry, and accessing an entry if it does exist. If I remove the tests to see if there is an entry in the dictionary for an adjacent block, or if the block type itself is seethrough, it runs within about 2-4 milliseconds. so here's my question: Is there a faster way to check for an entry in a dictionary than .ContainsKey()? As an aside, I tried TryGetValue() and it doesn't really help with the speed that much. If I remove the ContainsKey() and keep the test where it does the IsSeeThrough for each block, it halves the time, but it's still about 2-3 seconds. It only drops to 2-4ms if I remove BOTH checks. Here is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; using OpenTK; using OpenTK.Graphics.OpenGL; using System.Drawing; namespace Anabelle_Lee { public enum BlockEnum { air = 0, dirt = 1, } [StructLayout(LayoutKind.Sequential,Pack=1)] public struct Coordinates<T1> { public T1 x; public T1 y; public T1 z; public override string ToString() { return "(" + x + "," + y + "," + z + ") : " + typeof(T1); } } public struct Sides<T1> { public T1 left; public T1 right; public T1 top; public T1 bottom; public T1 front; public T1 back; } public class Block { public int blockType; public bool SeeThrough() { switch (blockType) { case 0: return true; } return false ; } public override string ToString() { return ((BlockEnum)(blockType)).ToString(); } } class Chunk { private Dictionary<Coordinates<byte>, Block> mChunkData; //stores the block data private Sides<List<Coordinates<byte>>> mVBOVertexBuffer; private Sides<int> mVBOHandle; //private bool mIsChanged; private const byte mCHUNKSIZE = 16; public Chunk() { } public void InitializeChunk() { //create VBO references #if DEBUG Console.WriteLine ("Initializing Chunk"); #endif mChunkData = new Dictionary<Coordinates<byte> , Block>(); //mIsChanged = true; GL.GenBuffers(1, out mVBOHandle.left); GL.GenBuffers(1, out mVBOHandle.right); GL.GenBuffers(1, out mVBOHandle.top); GL.GenBuffers(1, out mVBOHandle.bottom); GL.GenBuffers(1, out mVBOHandle.front); GL.GenBuffers(1, out mVBOHandle.back); //make new list of vertexes for each face mVBOVertexBuffer.top = new List<Coordinates<byte>>(); mVBOVertexBuffer.bottom = new List<Coordinates<byte>>(); mVBOVertexBuffer.left = new List<Coordinates<byte>>(); mVBOVertexBuffer.right = new List<Coordinates<byte>>(); mVBOVertexBuffer.front = new List<Coordinates<byte>>(); mVBOVertexBuffer.back = new List<Coordinates<byte>>(); #if DEBUG Console.WriteLine("Chunk Initialized"); #endif } public void GenerateChunk() { #if DEBUG Console.WriteLine("Generating Chunk"); #endif for (byte i = 0; i < mCHUNKSIZE; i++) { for (byte j = 0; j < mCHUNKSIZE; j++) { for (byte k = 0; k < mCHUNKSIZE; k++) { Random blockLoc = new Random(); Coordinates<byte> randChunk = new Coordinates<byte> { x = i, y = j, z = k }; mChunkData.Add(randChunk, new Block()); mChunkData[randChunk].blockType = blockLoc.Next(0, 1); } } } #if DEBUG Console.WriteLine("Chunk Generated"); #endif } public void DeleteChunk() { //delete VBO references #if DEBUG Console.WriteLine("Deleting Chunk"); #endif GL.DeleteBuffers(1, ref mVBOHandle.left); GL.DeleteBuffers(1, ref mVBOHandle.right); GL.DeleteBuffers(1, ref mVBOHandle.top); GL.DeleteBuffers(1, ref mVBOHandle.bottom); GL.DeleteBuffers(1, ref mVBOHandle.front); GL.DeleteBuffers(1, ref mVBOHandle.back); //clear all vertex buffers ClearPolyLists(); #if DEBUG Console.WriteLine("Chunk Deleted"); #endif } public void UpdateChunk() { #if DEBUG Console.WriteLine("Updating Chunk"); #endif ClearPolyLists(); //prepare buffers //for every entry in mChunkData map foreach(KeyValuePair<Coordinates<byte>,Block> feBlockData in mChunkData) { Coordinates<byte> checkBlock = new Coordinates<byte> { x = feBlockData.Key.x, y = feBlockData.Key.y, z = feBlockData.Key.z }; //check for polygonson the left side of the cube if (checkBlock.x > 0) { //check to see if there is a key for current x - 1. if not, add the vector if (!IsVisible(checkBlock.x - 1, checkBlock.y, checkBlock.z)) { //add polygon AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.left); } } else { //polygon is far left and should be added AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.left); } //check for polygons on the right side of the cube if (checkBlock.x < mCHUNKSIZE - 1) { if (!IsVisible(checkBlock.x + 1, checkBlock.y, checkBlock.z)) { //add poly AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.right); } } else { //poly for right add AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.right); } if (checkBlock.y > 0) { //check to see if there is a key for current x - 1. if not, add the vector if (!IsVisible(checkBlock.x, checkBlock.y - 1, checkBlock.z)) { //add polygon AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.bottom); } } else { //polygon is far left and should be added AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.bottom); } //check for polygons on the right side of the cube if (checkBlock.y < mCHUNKSIZE - 1) { if (!IsVisible(checkBlock.x, checkBlock.y + 1, checkBlock.z)) { //add poly AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.top); } } else { //poly for right add AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.top); } if (checkBlock.z > 0) { //check to see if there is a key for current x - 1. if not, add the vector if (!IsVisible(checkBlock.x, checkBlock.y, checkBlock.z - 1)) { //add polygon AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.back); } } else { //polygon is far left and should be added AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.back); } //check for polygons on the right side of the cube if (checkBlock.z < mCHUNKSIZE - 1) { if (!IsVisible(checkBlock.x, checkBlock.y, checkBlock.z + 1)) { //add poly AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.front); } } else { //poly for right add AddPoly(checkBlock.x, checkBlock.y, checkBlock.z, mVBOHandle.front); } } BuildBuffers(); #if DEBUG Console.WriteLine("Chunk Updated"); #endif } public void RenderChunk() { } public void LoadChunk() { #if DEBUG Console.WriteLine("Loading Chunk"); #endif #if DEBUG Console.WriteLine("Chunk Deleted"); #endif } public void SaveChunk() { #if DEBUG Console.WriteLine("Saving Chunk"); #endif #if DEBUG Console.WriteLine("Chunk Saved"); #endif } private bool IsVisible(int pX,int pY,int pZ) { Block testBlock; Coordinates<byte> checkBlock = new Coordinates<byte> { x = Convert.ToByte(pX), y = Convert.ToByte(pY), z = Convert.ToByte(pZ) }; if (mChunkData.TryGetValue(checkBlock,out testBlock )) //if data exists { if (testBlock.SeeThrough() == true) //if existing data is not seethrough { return true; } } return true; } private void AddPoly(byte pX, byte pY, byte pZ, int BufferSide) { //create temp array GL.BindBuffer(BufferTarget.ArrayBuffer, BufferSide); if (BufferSide == mVBOHandle.front) { //front face mVBOVertexBuffer.front.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.front.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY) , z = (byte)(pZ + 1) }); mVBOVertexBuffer.front.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY) , z = (byte)(pZ + 1) }); mVBOVertexBuffer.front.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY) , z = (byte)(pZ + 1) }); mVBOVertexBuffer.front.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.front.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY + 1), z = (byte)(pZ + 1) }); } else if (BufferSide == mVBOHandle.right) { //back face mVBOVertexBuffer.back.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ) }); mVBOVertexBuffer.back.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY) , z = (byte)(pZ) }); mVBOVertexBuffer.back.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY) , z = (byte)(pZ) }); mVBOVertexBuffer.back.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY) , z = (byte)(pZ) }); mVBOVertexBuffer.back.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY + 1), z = (byte)(pZ) }); mVBOVertexBuffer.back.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ) }); } else if (BufferSide == mVBOHandle.top) { //left face mVBOVertexBuffer.left.Add(new Coordinates<byte> { x = (byte)(pX), y = (byte)(pY + 1), z = (byte)(pZ) }); mVBOVertexBuffer.left.Add(new Coordinates<byte> { x = (byte)(pX), y = (byte)(pY) , z = (byte)(pZ) }); mVBOVertexBuffer.left.Add(new Coordinates<byte> { x = (byte)(pX), y = (byte)(pY) , z = (byte)(pZ + 1) }); mVBOVertexBuffer.left.Add(new Coordinates<byte> { x = (byte)(pX), y = (byte)(pY) , z = (byte)(pZ + 1) }); mVBOVertexBuffer.left.Add(new Coordinates<byte> { x = (byte)(pX), y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.left.Add(new Coordinates<byte> { x = (byte)(pX), y = (byte)(pY + 1), z = (byte)(pZ) }); } else if (BufferSide == mVBOHandle.bottom) { //right face mVBOVertexBuffer.right.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.right.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY) , z = (byte)(pZ + 1) }); mVBOVertexBuffer.right.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY) , z = (byte)(pZ) }); mVBOVertexBuffer.right.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY) , z = (byte)(pZ) }); mVBOVertexBuffer.right.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ) }); mVBOVertexBuffer.right.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ + 1) }); } else if (BufferSide == mVBOHandle.front) { //top face mVBOVertexBuffer.top.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY + 1), z = (byte)(pZ) }); mVBOVertexBuffer.top.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.top.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.top.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ + 1) }); mVBOVertexBuffer.top.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY + 1), z = (byte)(pZ) }); mVBOVertexBuffer.top.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY + 1), z = (byte)(pZ) }); } else if (BufferSide == mVBOHandle.back) { //bottom face mVBOVertexBuffer.bottom.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY), z = (byte)(pZ + 1) }); mVBOVertexBuffer.bottom.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY), z = (byte)(pZ) }); mVBOVertexBuffer.bottom.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY), z = (byte)(pZ) }); mVBOVertexBuffer.bottom.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY), z = (byte)(pZ) }); mVBOVertexBuffer.bottom.Add(new Coordinates<byte> { x = (byte)(pX + 1), y = (byte)(pY), z = (byte)(pZ + 1) }); mVBOVertexBuffer.bottom.Add(new Coordinates<byte> { x = (byte)(pX) , y = (byte)(pY), z = (byte)(pZ + 1) }); } } private void BuildBuffers() { #if DEBUG Console.WriteLine("Building Chunk Buffers"); #endif GL.BindBuffer(BufferTarget.ArrayBuffer, mVBOHandle.front); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf(new Coordinates<byte>()) * mVBOVertexBuffer.front.Count), mVBOVertexBuffer.front.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, mVBOHandle.back); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf(new Coordinates<byte>()) * mVBOVertexBuffer.back.Count), mVBOVertexBuffer.back.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, mVBOHandle.left); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf(new Coordinates<byte>()) * mVBOVertexBuffer.left.Count), mVBOVertexBuffer.left.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, mVBOHandle.right); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf(new Coordinates<byte>()) * mVBOVertexBuffer.right.Count), mVBOVertexBuffer.right.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, mVBOHandle.top); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf(new Coordinates<byte>()) * mVBOVertexBuffer.top.Count), mVBOVertexBuffer.top.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, mVBOHandle.bottom); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Marshal.SizeOf(new Coordinates<byte>()) * mVBOVertexBuffer.bottom.Count), mVBOVertexBuffer.bottom.ToArray(), BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer,0); #if DEBUG Console.WriteLine("Chunk Buffers Built"); #endif } private void ClearPolyLists() { #if DEBUG Console.WriteLine("Clearing Polygon Lists"); #endif mVBOVertexBuffer.top.Clear(); mVBOVertexBuffer.bottom.Clear(); mVBOVertexBuffer.left.Clear(); mVBOVertexBuffer.right.Clear(); mVBOVertexBuffer.front.Clear(); mVBOVertexBuffer.back.Clear(); #if DEBUG Console.WriteLine("Polygon Lists Cleared"); #endif } }//END CLASS }//END NAMESPACE

    Read the article

  • StackOverflowException throws often when .net application built with Debug mode

    - by user1487950
    I have an application which access an external webservice often, when i are trying to debug it, means debuging in vistual studio. it often throws out StackOverflowException at the webserverice call point. when building in Release mode , the exception thrown out only occasionally. I checked the call stack, looks like there is no recursive call. can you please suggest? thank you very much. call statck attached. [In a sleep, wait, or join] mscorlib.dll!System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) + 0x2b bytes mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) + 0x2d bytes System.dll!System.Net.NetworkAddressChangePolled.CheckAndReset() + 0x9d bytes System.dll!System.Net.NclUtilities.LocalAddresses.get() + 0x49 bytes System.dll!System.Net.WebProxyScriptHelper.myIpAddress() + 0x27 bytes [Native to Managed Transition] System.dll!System.Net.WebProxyScriptHelper.MyMethodInfo.Invoke(object target, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, object[] args, System.Globalization.CultureInfo culture) + 0x6b bytes MTOqoHCT.dll!JScript 0.myIpAddress(object this, Microsoft.JScript.Vsa.VsaEngine vsa Engine, object arguments) + 0x91 bytes MTOqoHCT.dll!JScript 0.FindProxyForURL(object this, Microsoft.JScript.Vsa.VsaEngine vsa Engine, object arguments, object url, object host) + 0x3c6e bytes MTOqoHCT.dll!__WebProxyScript.__WebProxyScript.ExecuteFindProxyForURL(object url, object host) + 0x11d bytes [Native to Managed Transition] Microsoft.JScript.dll!System.Net.VsaWebProxyScript.CallMethod(object targetObject, string name, object[] args) + 0x11a bytes Microsoft.JScript.dll!System.Net.VsaWebProxyScript.Run(string url, string host) + 0x74 bytes [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, int methodPtr, bool fExecuteInContext) + 0x1ef bytes mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0xf bytes mscorlib.dll!System.Runtime.Remoting.Messaging.ServerObjectTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x66 bytes mscorlib.dll!System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x8a bytes mscorlib.dll!System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessageCallback(object[] args) + 0x94 bytes mscorlib.dll!System.Threading.Thread.CompleteCrossContextCallback(System.Threading.InternalCrossContextDelegate ftnToCall, object[] args) + 0x8 bytes [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0xa7 bytes mscorlib.dll!System.Runtime.Remoting.Channels.ChannelServices.SyncDispatchMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0x92 bytes mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, out System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0xed bytes mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(object[] args) + 0x8a bytes mscorlib.dll!System.Threading.Thread.CompleteCrossContextCallback(System.Threading.InternalCrossContextDelegate ftnToCall, object[] args) + 0x8 bytes [Appdomain Transition] mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, out System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x74 bytes mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0xa3 bytes mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink ms, System.Runtime.Remoting.Messaging.IMessage reqMsg, System.Runtime.Remoting.Contexts.ArrayWithSize proxySinks, System.Threading.Thread currentThread, System.Runtime.Remoting.Contexts.Context currentContext, bool bSkippingContextChain) + 0x50 bytes mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType) + 0x1d5 bytes mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x66 bytes mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0xee bytes System.dll!System.Net.NetWebProxyFinder.GetProxies(System.Uri destination, out System.Collections.Generic.IList<string> proxyList) + 0x83 bytes System.dll!System.Net.AutoWebProxyScriptEngine.GetProxies(System.Uri destination, out System.Collections.Generic.IList<string> proxyList, ref int syncStatus) + 0x84 bytes System.dll!System.Net.WebProxy.GetProxiesAuto(System.Uri destination, ref int syncStatus) + 0x2e bytes System.dll!System.Net.ProxyScriptChain.GetNextProxy(out System.Uri proxy) + 0x2e bytes System.dll!System.Net.ProxyChain.ProxyEnumerator.MoveNext() + 0x98 bytes System.dll!System.Net.ServicePointManager.FindServicePoint(System.Uri address, System.Net.IWebProxy proxy, out System.Net.ProxyChain chain, ref System.Net.HttpAbortDelegate abortDelegate, ref int abortState) + 0x120 bytes System.dll!System.Net.HttpWebRequest.FindServicePoint(bool forceFind) + 0xb1 bytes System.dll!System.Net.HttpWebRequest.GetRequestStream(out System.Net.TransportContext context) + 0x247 bytes System.dll!System.Net.HttpWebRequest.GetRequestStream() + 0xe bytes System.Web.Services.dll!System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(string methodName, object[] parameters) + 0xc0 bytes Gfinet.Config.dll!Gfinet.Config.Service.cfg_webservice.addOrUpdateProperties(string string, int intVal, Gfinet.Config.Service.PropertiesDataM[] propertiesDataMs) + 0xa3 bytes Gfinet.Config.dll!Gfinet.Config.Service.WSServiceImpl.AddOrUpdateProperties(int setId, Gfinet.Config.Service.PropertiesDataM[] properties) + 0x46 bytes [Native to Managed Transition] Gfinet.Config.dll!Gfinet.Config.Service.ServiceAspect.InvocationHandler(object target, System.Reflection.MethodBase method, object[] parameters) + 0x49e bytes Gfinet.Config.dll!Gfinet.Config.DynamicProxy.DynamicProxyImpl.Invoke(System.Runtime.Remoting.Messaging.IMessage message) + 0x110 bytes mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(ref System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0xee bytes Tici.Kraps.Services.dll!Tici.Kraps.Services.Configuration.GFINetConfiguration.StoreElement(string application, string category, string id, string elementValue, bool save) Line 303 + 0x55 bytes C# Tici.Kraps.Services.dll!Tici.Kraps.Services.Configuration.GFINetConfiguration.SaveAllInternal() Line 582 + 0x6e bytes C# Tici.Kraps.Services.dll!Tici.Kraps.Services.Configuration.GFINetConfiguration.SaveAll(bool async) Line 434 + 0x8 bytes C# Tici.Kraps.Services.dll!Tici.Kraps.Services.Configuration.GFINetConfiguration.SaveAll() Line 406 + 0xa bytes C# Tici.Kraps.Services.dll!Tici.Kraps.Services.Container.Persistor.Save() Line 59 + 0xc bytes C# Spark.exe!Tici.Kraps.RibbonShell.OnBtnSaveWorkspaceItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) Line 642 + 0xf bytes C# DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.BarItem.OnClick(DevExpress.XtraBars.BarItemLink link) + 0x108 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.BarBaseButtonItem.OnClick(DevExpress.XtraBars.BarItemLink link) + 0x47 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.BarItemLink.OnLinkClick() + 0x245 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.BarItemLink.OnLinkAction(DevExpress.XtraBars.BarLinkAction action, object actionArgs) + 0xb3 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(DevExpress.XtraBars.BarLinkAction action, object actionArgs) + 0x47e bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.BarItemLink.OnLinkActionCore(DevExpress.XtraBars.BarLinkAction action, object actionArgs) + 0x82 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(DevExpress.XtraBars.BarItemLink link) + 0x85 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(DevExpress.XtraBars.BarItemLink link) + 0x1e5 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPressItem(DevExpress.Utils.DXMouseEventArgs e, DevExpress.XtraBars.Ribbon.ViewInfo.RibbonHitInfo hitInfo) + 0xa7 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPress(DevExpress.Utils.DXMouseEventArgs e, DevExpress.XtraBars.Ribbon.ViewInfo.RibbonHitInfo hitInfo) + 0x5f bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnMouseUp(DevExpress.Utils.DXMouseEventArgs e) + 0x19a bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.Ribbon.Handler.RibbonHandler.OnMouseUp(DevExpress.Utils.DXMouseEventArgs e) + 0x47 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.Ribbon.RibbonControl.OnMouseUp(System.Windows.Forms.MouseEventArgs e) + 0x95 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WmMouseUp(ref System.Windows.Forms.Message m, System.Windows.Forms.MouseButtons button, int clicks) + 0x2d1 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x93a bytes DevExpress.Utils.v11.2.dll!DevExpress.Utils.Controls.ControlBase.WndProc(ref System.Windows.Forms.Message m) + 0x81 bytes DevExpress.XtraBars.v11.2.dll!DevExpress.XtraBars.Ribbon.RibbonControl.WndProc(ref System.Windows.Forms.Message m) + 0x85 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0x13 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x31 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x96 bytes [Native to Managed Transition] [Managed to Native Transition] DevExpress.Utils.v11.2.dll!DevExpress.Utils.Win.Hook.ControlWndHook.WindowProc(System.IntPtr hWnd, int message, System.IntPtr wParam, System.IntPtr lParam) + 0x159 bytes [Native to Managed Transition] [Managed to Native Transition] System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) + 0x287 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) + 0x16c bytes System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31 bytes Tici.Kraps.Services.dll!Tici.Kraps.Services.Container.DefaultApplicationRunner.Run() Line 41 + 0x17 bytes C# Kraps.exe!Tici.Kraps.Program.Main() Line 105 + 0x9 bytes C# [Native to Managed Transition] [Managed to Native Transition] mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6d bytes Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2a bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes [Native to Managed Transition]

    Read the article

  • Explanation of SendMessage message numbers? (C#, Winforms)

    - by John
    I've successfully used the Windows SendMessage method to help me do various things in my text editor, but each time I am just copying and pasting code suggested by others, and I don't really know what it means. There is always a cryptic message number that is a parameter. How do I know what these code numbers mean so that I can actually understand what is happening and (hopefully) be a little more self-sufficient in the future? Thanks. Recent example: using System.Runtime.InteropServices; [DllImport("user32.dll")] static extern int SendMessage(IntPtr hWnd, uint wMsg,UIntPtr wParam, IntPtr lParam); SendMessage(myRichTextBox.Handle, (uint)0x00B6, (UIntPtr)0, (IntPtr)(-1));

    Read the article

  • Is there a good way to convert between BitmapSource and Bitmap?

    - by JohannesH
    As far as I can tell the only way to convert from BitmapSource to Bitmap is through unsafe code... Like this (from Lesters WPF blog): myBitmapSource.CopyPixels(bits, stride, 0); unsafe { fixed (byte* pBits = bits) { IntPtr ptr = new IntPtr(pBits); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap( width, height, stride, System.Drawing.Imaging.PixelFormat.Format32bppPArgb,ptr); return bitmap; } } To do the reverse: System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); Is there an easier way in the framework? And what is the reason it isn't in there (if it's not)? I would think it's fairly usable. The reason I need it is because I use AForge to do certain image operations in an WPF app. WPF wants to show BitmapSource/ImageSource but AForge works on Bitmaps.

    Read the article

  • Handling exception from unmanaged dll in C#

    - by StuffHappens
    Hello. I have the following function written in C# public static string GetNominativeDeclension(string surnameNamePatronimic) { if(surnameNamePatronimic == null) throw new ArgumentNullException("surnameNamePatronimic"); IntPtr[] ptrs = null; try { ptrs = StringsToIntPtrArray(surnameNamePatronimic); int resultLen = MaxResultBufSize; int err = decGetNominativePadeg(ptrs[0], ptrs[1], ref resultLen); ThrowException(err); return IntPtrToString(ptrs, resultLen); } catch { return surnameNamePatronimic; } finally { FreeIntPtr(ptrs); } } Function decGetNominativePadeg is in unmanaged dll [DllImport("Padeg.dll", EntryPoint = "GetNominativePadeg")] private static extern Int32 decGetNominativePadeg(IntPtr surnameNamePatronimic, IntPtr result, ref Int32 resultLength); and throws an exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. The catch that is in C# code doesn't actually catch it. Why? How to handle this exception? Thank you for your help!

    Read the article

  • Unable to get the Current User's Token information

    - by Ram
    Hi, I have been trying to get the currently logged-in user's token information using the following code : [DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern bool WTSQueryUserToken(int sessionId, out IntPtr tokenHandle); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern uint WTSGetActiveConsoleSessionId(); static void Main(string[] args) { try { int sessionID = (int)WTSGetActiveConsoleSessionId(); if (sessionID != -1) { System.IntPtr currentToken = IntPtr.Zero; bool bRet = WTSQueryUserToken(sessionID, out currentToken); Console.WriteLine("bRet : " + bRet.ToString()); } } catch (Exception) { } } The problem is that, bRet is always false and currentToken is always 0. I am getting the sessionid as 1. Could someone tell me what's going wrong here? I want to use this token information to pass it to the CreateProcessAsUser function from a windows service. Thanks, Ram

    Read the article

  • NativeWindow WndProc not receiving messages

    - by BadNinja
    Could someone shed some light on why my WndProc method as implemented below isn't receiving any messages? If I put this class below in a WinForms application and pass in that application's handle, WndProc receives messages as I would expect. However, using the IntPtr returned from GetForegroundWindow() as I have below doesn't yield the same results. (FWIW, I have my code set up to execute GetForegroundWindow() when my application is hidden, so I'm certain that the IntPtr is referring to an outside application.) public class MyNativeWindow : NativeWindow { [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)] private static extern IntPtr GetForegroundWindow(); public MyNativeWindow() { this.AssignHandle(GetForegroundWindow()); } // Never called... I set a breakpoint [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { base.WndProc(ref m); } }

    Read the article

  • How can I overwrite a System.Drawing.Bitmap onto an existing GDI bitmap?

    - by MusiGenesis
    If I have a .Net Bitmap, I can create from it a GDI bitmap by calling the Bitmap's GetHbitmap() method. Bitmap bmp = new Bitmap(100, 100); IntPtr gdiBmp = bmp.GetHbitmap(); This works fine, but every time you call GetHbitmap, Windows has to allocate new memory for the object that gdiBmp references. What I'd like to do - if possible - is write a function (I know PInvoke will be necessary here) that also generates a GDI bitmap copy of a Bitmap, but that uses an existing object instead of allocating a new one. So it would look something like this (if it were an extension method of Bitmap): //void OverwriteHbitmap(IntPtr gdi) Bitmap bmp1 = new Bitmap(100, 100); IntPtr gdi1 = bmp1.GetHbitmap(); Bitmap bmp2 = new Bitmap(100, 100); bmp2.OverwriteHbitmap(gdi1); How can I do this? I assume I'll need to know the structure of a GDI bitmap, and probably I can use LockBits and BitmapData for this, but I'm not sure exactly how.

    Read the article

  • Windows Authentication for winforms with Windows 2000

    - by The King
    I use the following code to validate users through windows authentication for my winform application. This works fine with windows XP but when the user is using windows 2000, it says that the userid or password is in valid. How do I do this in Windows 2000. Further, How do I detect whether the user is using Windows Xp or windows 2000. [System.Runtime.InteropServices.DllImport("advapi32.dll")] public static extern bool LogonUser(string userName, string domainName, string password, int LogonType, int LogonProvider, ref IntPtr phToken); public bool IsValidateCredentials(string userName, string password, string domain) { IntPtr tokenHandler = IntPtr.Zero; bool isValid = LogonUser(userName, domain, password, 2, 0, ref tokenHandler); return isValid; } Thanks

    Read the article

  • System.AccessViolation in DllImport method after redeploy

    - by gall
    Hi Everyone, My environment: Windows 2003, VS 2008, .NET 3.5 C# .NET application. During loading my application I call method from C++ dll (Knowl.dll) through my third-party dll library (Common.dll) written in C#. After first deploy (from VS to Developing server) evrything works fine. Then I stops Developing Server, doesn't any changes in code and redeploy. Throws AccessViolationException on this imported method. What is it? On second and after redeplies - the same error. Only after deletin source code and recheckout it from CVS I can normally start server. Dll import: [DllImport("Knowl.dll", EntryPoint = "GetBaseName")] private static extern IntPtr getNameDll(); public static string GetName() { IntPtr p = IntPtr.Zero; p = getNameDll(); return Marshal.PtrToStringUni(p); }

    Read the article

  • GetDC() DllImport for x64 apps

    - by devdept
    If you make a little research on the internet you'll see many DLLImport styles for this user32.dll function: HDC GetDC(HWND hWnd); The question is: what type is more appropriate for .NET x64 apps (either compiled with the Platform target as AnyCPU on a x64 machine or specifically as x64)? IntPtr for example grows to a size of 8 on a x64 process, can this be a problem? Is uint more appropriate than Uint64? What is the size of the pointers this function uses when used in a x64 process? The DLL is called user32.dll does it work as 32bit or 64bit on a x64 operating system? [DllImport("user32.dll",EntryPoint="GetDC")] public static extern IntPtr GetDC(IntPtr hWnd); public static extern uint GetDC(uint hWnd); public static extern int GetDC(int hWnd); Thanks!

    Read the article

  • Using SetThreadAffinityMask function imported from kernel32.dll in C # code.

    - by DotNetBeginner
    I am trying to set Thread Affinity using SetThreadAffinityMask function imported from kernel32.dll in C # code of mine. This is how I import SetThreadAffinityMask function from "kernel32.dll" in my C# .net code [DllImport("kernel32.dll")] static extern IntPtr SetThreadAffinityMask(IntPtr hThread, IntPtr dwThreadAffinityMask); I am creating 3 threads Thread t1=new Thread(some delegate); Thread t2=new Thread(some delegate); Thread t3=new Thread(some delegate); I wish to set Thread affinity for t1,t2 & t3 for which I am using SetThreadAffinityMask function. But I am not getting how to pass parameters to this function. SetThreadAffinityMask takes two parameters 1. HANDLE hThread 2. DWORD_PTR dwThreadAffinityMask Please help me in using SetThreadAffinityMask function in C# Thanks in advance !

    Read the article

  • Handling exception form unmanaged dll in C#

    - by StuffHappens
    Hello. I have the following function written in C# public static string GetNominativeDeclension(string surnameNamePatronimic) { if(surnameNamePatronimic == null) throw new ArgumentNullException("surnameNamePatronimic"); IntPtr[] ptrs = null; try { ptrs = StringsToIntPtrArray(surnameNamePatronimic); int resultLen = MaxResultBufSize; int err = decGetNominativePadeg(ptrs[0], ptrs[1], ref resultLen); ThrowException(err); return IntPtrToString(ptrs, resultLen); } catch { return surnameNamePatronimic; } finally { FreeIntPtr(ptrs); } } Function decGetNominativePadeg is in unmanaged dll [DllImport("Padeg.dll", EntryPoint = "GetNominativePadeg")] private static extern Int32 decGetNominativePadeg(IntPtr surnameNamePatronimic, IntPtr result, ref Int32 resultLength); and throws an exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. The catch that is in C# code doesn't actually catch it. Why? How to handle this exception? Thank you for your help!

    Read the article

  • .NET 2.0 vs .NET 4.0 loading error

    - by David Rutten
    My class library is compiled against .NET 2.0 and works just fine whenever I try to load it as a plugin under the 2.0 runtime. If however the master application is running the .NET 4.0 runtime, I get an exception as soon as the resources need to be accessed: Exception occurred during processing of command: Grasshopper Plug-in = Grasshopper Could not find file 'Grasshopper.resources'. Stack trace: at UnhandledExceptionLogger.UnhandledThreadException(Object sender, ThreadExceptionEventArgs args) at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t) at System.Windows.Forms.Control.WndProcException(Exception e) at System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(Handle Ref hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.Show(IWin32Window owner) .... What's going on and how do I make my project load on all .NET Runtimes?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >