¡@

Home 

c# Programming Glossary: marshal

Calling ShowDialog in BackgroundWorker

http://stackoverflow.com/questions/10498555/calling-showdialog-in-backgroundworker

main form would be a good choice and then use Invoke to marshal a request for user interaction to your UI thread. A barebones..

How do I access ARP-protocol information through .NET?

http://stackoverflow.com/questions/1148778/how-do-i-access-arp-protocol-information-through-net

Win32Exception result Now we have the buffer we have to marshal it. We can read the first 4 bytes to get the length of the..

How to marshal a variable sized array of structs? C# and C++ interop help

http://stackoverflow.com/questions/1197181/how-to-marshal-a-variable-sized-array-of-structs-c-sharp-and-c-interop-help

to marshal a variable sized array of structs C# and C interop help I have.. And a C function OuterStruct getStructs How can I marshal this to C# Where the C# definitions is struct OuterStruct InnerStruct.. InnerStruct innerStructs c# .net interop pinvoke marshalling share improve this question You'll have to do this manually..

Drag and Drop between Instances of the same Windows Forms Application

http://stackoverflow.com/questions/1201812/drag-and-drop-between-instances-of-the-same-windows-forms-application

solution I came up with involves a helper class to help marshal the bitmap data between processes. First here is the class...

C#: Invoke(Delegate)

http://stackoverflow.com/questions/14703698/c-invokedelegate

thread you must use one of the control's invoke methods to marshal the call to the proper thread. This property can be used to..

TransactionScope automatically escalating to MSDTC on some machines?

http://stackoverflow.com/questions/1690892/transactionscope-automatically-escalating-to-msdtc-on-some-machines

and escalates it to an MSDTC transaction. A request to marshal the transaction to a different application domain or different.. an application domain boundary. The transaction object is marshaled by value meaning that any attempt to pass it across an application..

Write an Rx “RetryAfter” extension method

http://stackoverflow.com/questions/18978523/write-an-rx-retryafter-extension-method

T t.Item3 All of those angle brackets are there to marshal an exception for which we shouldn't retry past the .Retry ...

What is a message pump?

http://stackoverflow.com/questions/2222365/what-is-a-message-pump

message loop is important because that's what COM uses to marshal an interface method call from one thread to another. Although.. call from one thread to another. Although .NET makes marshaling calls easy Control.BeginInvoke or Dispatcher.BeginInvoke.. is executing the message loop it is idle. The actual marshaling takes place through a hidden window that COM creates it uses..

Cleanest Way to Invoke Cross-Thread Events

http://stackoverflow.com/questions/22356/cleanest-way-to-invoke-cross-thread-events

another thread. I was wondering what the cleanest way to marshal an event from a background thread onto my UI thread is. Based..

Read binary file into a struct

http://stackoverflow.com/questions/2384/read-binary-file-into-a-struct

The problem is the string s in your struct. I found that marshaling types like byte short int is not a problem but when you need.. like byte short int is not a problem but when you need to marshal into a complex type such as a string you need your struct to..

Access VBA equivalent to a C# List<T>

http://stackoverflow.com/questions/3497982/access-vba-equivalent-to-a-c-sharp-listt

access vba share improve this question You can't marshal generics but using Collection on the VB6 side is a workable..

PInvoke for C function that returns char *

http://stackoverflow.com/questions/370079/pinvoke-for-c-function-that-returns-char

memory was allocated with CoTaskMemAlloc Therefore it will marshal the string and then call CoTaskMemFree on the native memory..

Marshal C++ int array to C#

http://stackoverflow.com/questions/3776485/marshal-c-int-array-to-c-sharp

C int array to C# I would like to marshal an array of ints from C to C#. I have an unmanaged C dll which.. DLL_EXPORT int fnwrapper_intarr I am then using pinvoke to marshal it into C# DllImport wrapper_demo_d.dll return MarshalAs UnmanagedType.SafeArray.. execution I get the following error SafeArray cannot be marshaled to this array type because it has either nonzero lower bounds..

C# Marshalling double* from C++ DLL?

http://stackoverflow.com/questions/5072340/c-sharp-marshalling-double-from-c-dll

0 0 0 0 I get a MarshalDirectiveException exception Cannot marshal 'return value' Invalid managed unmanaged type combination. I'm.. rather than a MarshalDirectiveException. c# c interop marshalling dllimport share improve this question There are a few.. The C code has no idea how big those arrays are. The marshaller will pass them a valid pointer but without a corresponding..

Does the System.Windows.Forms.Timer run on a different thread than the UI?

http://stackoverflow.com/questions/5694469/does-the-system-windows-forms-timer-run-on-a-different-thread-than-the-ui

pump available and always operate from the same thread or marshal the call onto another thread. When you use this timer use the..

Marshaling c structures in c#

http://stackoverflow.com/questions/9188523/marshaling-c-structures-in-c-sharp

fallowing are the sample structures i have in c i have to marshal those structures in my c# code is i'm doing correct or wrong.. procedure p45_cldxed 8 p45_cldxed24 c# c struct pinvoke marshalling share improve this question Scratch my original answer..

C# Excel automation causes Excel memory leak

http://stackoverflow.com/questions/13483523/c-sharp-excel-automation-causes-excel-memory-leak

I read about how you need to use Marshal to release uses so I'm now trying the following code but have.. Excel.XlCalculation.xlCalculationAutomatic int x Marshal.ReleaseComObject currWorkbook currWorkbook null int y Marshal.ReleaseComObject.. currWorkbook currWorkbook null int y Marshal.ReleaseComObject currWorkbooks currWorkbooks null c# excel..

C# performance - Using unsafe pointers instead of IntPtr and Marshal

http://stackoverflow.com/questions/17549123/c-sharp-performance-using-unsafe-pointers-instead-of-intptr-and-marshal

performance Using unsafe pointers instead of IntPtr and Marshal Question I'm porting a C application into C#. The C app calls.. data which I have to use in the C# app so I used IntPtr 's Marshal.PtrToStructure and Marshal.Copy to copy the native data arrays.. the C# app so I used IntPtr 's Marshal.PtrToStructure and Marshal.Copy to copy the native data arrays and structures into managed..

Size of managed structures

http://stackoverflow.com/questions/2127707/size-of-managed-structures

of bytes in the example is 3 2 1 not 5 1 4 as returned by Marshal.SizeOf. Note 2 sizeof cannot determine the size of generic type.. uint Delegate.CreateDelegate typeof Func Type uint typeof Marshal .GetMethod SizeOfType BindingFlags.NonPublic BindingFlags.Static..

How can I pass a pointer to an array using p/invoke in C#?

http://stackoverflow.com/questions/289076/how-can-i-pass-a-pointer-to-an-array-using-p-invoke-in-c

also be able to declare the parameter as an IntPtr and Marshal the data manually. DllImport EntryPoint func CharSet CharSet.Auto.. static void Func IntPtr p byte ar new byte 1000 IntPtr p Marshal.AllocHGlobal Marshal.SizeOf ar Marshal.Copy ar 0 p ar.Length.. p byte ar new byte 1000 IntPtr p Marshal.AllocHGlobal Marshal.SizeOf ar Marshal.Copy ar 0 p ar.Length Func p Marshal.FreeHGlobal..

Marshal C++ int array to C#

http://stackoverflow.com/questions/3776485/marshal-c-int-array-to-c-sharp

C int array to C# I would like to marshal an array of ints.. to marshal it into C# DllImport wrapper_demo_d.dll return MarshalAs UnmanagedType.SafeArray public static extern int fnwrapper_intarr.. IntPtr ptr fnwrapper_intarr int result new int 3 Marshal Copy ptr result 0 3 You need also to write Release function..

loading binary data into a structure

http://stackoverflow.com/questions/3863191/loading-binary-data-into-a-structure

CharSet.Ansi private struct Example public int mumble MarshalAs UnmanagedType.ByValTStr SizeConst 42 public string text etc..... member of the struct. There's a workaround for that the Marshal class already knows how to convert unmanaged structures to managed.. ref T retval if index buffer.Length return false int size Marshal.SizeOf typeof T if index size buffer.Length throw new IndexOutOfRangeException..

Get ListView items from other windows

http://stackoverflow.com/questions/4857602/get-listview-items-from-other-windows

makes things quite a bit easier on us here with the Marshal class . Once you've taken that into account it's a simple matter.. refers to an item rather than a subitem lvi.pszText Marshal.AllocHGlobal 512 Send the LVM_GETITEM message to fill the LVITEM.. message to fill the LVITEM structure IntPtr ptrLvi Marshal.AllocHGlobal Marshal.SizeOf lvi Marshal.StructureToPtr lvi ptrLvi..

When to use pointers in C#/.NET?

http://stackoverflow.com/questions/5171781/when-to-use-pointers-in-c-net

other than performance. You can use the methods in the Marshal class to deal with interoperating with unmanaged code in the.. any. Of course as I said if you are the person writing the Marshal class then obviously you don't get to use the marshalling layer..

Does MessageBox.Show() automatically marshall to the UI Thread?

http://stackoverflow.com/questions/559252/does-messagebox-show-automatically-marshall-to-the-ui-thread

marshalling share improve this question No it doesn't Marshal to the UI thread. If you think about it it wouldn't be possible..

Shortest way to write a thread-safe access method to a windows forms control

http://stackoverflow.com/questions/571706/shortest-way-to-write-a-thread-safe-access-method-to-a-windows-forms-control

Execute action. action Get out. return Marshal to the required context. sync.Invoke action new object You'd.. Execute action. action Get out. return Marshal to the required context. sync.Invoke action new object And..

Which PID listens on a given port in c#

http://stackoverflow.com/questions/577433/which-pid-listens-on-a-given-port-in-c-sharp

throw new Exception bad ret on check ret IntPtr buffTable Marshal.AllocHGlobal buffSize try ret GetExtendedTcpTable buffTable.. table MIB_TCPTABLE_OWNER_PID tab MIB_TCPTABLE_OWNER_PID Marshal.PtrToStructure buffTable typeof MIB_TCPTABLE_OWNER_PID IntPtr.. IntPtr rowPtr IntPtr long buffTable Marshal.SizeOf tab.dwNumEntries tTable new MIB_TCPROW_OWNER_PID tab.dwNumEntries..

Create Bitmap from a byte array of pixel data

http://stackoverflow.com/questions/6782489/create-bitmap-from-a-byte-array-of-pixel-data

is hard to determine. You can also alloc the memory using Marshal or use the unmanaged memory allocated by the Bitmap. I've done.. fill in rgbValues e.g. with a for loop over an input array Marshal.Copy rgbValues 0 ptr bytes b.UnlockBits bmpData return b share..

Safely disposing Excel interop objects in C#?

http://stackoverflow.com/questions/9962157/safely-disposing-excel-interop-objects-in-c

object obj try System.Runtime.InteropServices.Marshal.ReleaseComObject obj obj null catch Exception ex obj null MessageBox.Show.. System.Reflection.Missing.Value xlApp.Quit Marshal.ReleaseComObject xlWorkSheet Marshal.ReleaseComObject xlWorkBook.. xlApp.Quit Marshal.ReleaseComObject xlWorkSheet Marshal.ReleaseComObject xlWorkBook Marshal.ReleaseComObject xlApp..