I'm attempting to access a function in a DLL in C# and C++.
C++ is working fine, as is C# on WinXP. However I'm getting the following error when attempting to access the function on a Win2k8 system:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other...
In the course of finding a way to interoperate between C# and C++ I found this article that explains about P/Invoke.
And I read a lot of articles claiming that C++/CLI is not exact C++ and requires some effort to modify from original C++ code.
I want to ask what would be the optimal way when I have some C++ objects (code/data) that I ...
What DLL do I need to reference to access FilerRegister method(s) of the CRegObject from C#?
[DllImport("ATL90.DLL")]
public static extern int FileRegister(string fileName);
And how would I do that in visual studio?
Any help is greatly appreciated! I can't seem to find the correct DLL. I looked on pinvoke.net, but couldn't fi...
What should be the C# signiture for this function? (for pInvoke)
DWORD GetVatAccount(COleDateTime dtDateTime, BSTR FAR* strResult)
...
Functions such as CreateProcess have signatures taking several pointers to structs. In common C programming I would likely pass NULL as a pointer for the optional parameters, instead of creating a temporary struct object on the stack and passing a reference.
In C#, I have declared it as (p/invoke)
[DllImport("kernel32.dll", CharSet = ...
Hi,
I have a C++ function that I'd like to access from C#. The problem is I keep getting PInvokeStackImbalance exceptions and I don't know why. Everything runs fine and as expected when checking for that exception is turned off.
The signature of my C++ function is:
extern "C" double solveQP(
int32_t n, int32_t mE, int32_t mI,
...
Hello everyone,
Right now I am experimenting with the CreateVirtualDisk function to create a VHD from both physical disk and virtual disk. I have got stuck here for one week because of the error: Access is denied when I tried to create a VHD from a physical disk. I always ran the program with the administrator rights so in theory it sho...
I wrote my program in C++ and exported it as a DLL. I have a C# WPF GUI and I want to import the DLL to do the processing.
I am very new to C#. How can I use the C++ class in C#? I know I can't just use the .h file.
Because I used pointers in C++, in C# I couldn't use pointers. That's why I got confused. Like in C++ i used char* instea...
Can anyone translate these two cryptui.dll functions/structures into C#.NET [dllimport] wrappers? I would like to P/Invoke the CryptUIWizExport function to display the Windows Certificate Export Wizard. In particular, I need to pass a .NET X509Certificate as a parameter into the CryptUIWizExport function. You help is much appreciated!!!
...
Hi All.
I'm invoking a C++ function from within C#.
This is the function header in C++ :
int src_simple (SRC_DATA *data, int converter_type, int channels) ;
And this is the equivilent C# function :
[DllImport("libsamplerate-0.dll")]
public static extern int src_simple(ref SRC_DATA sd, int converter_type, int channels);
This ...
I need a method that will make my form move to the top when other forms do not want them to.
I am not talking about myForm.BringToFront or myForm.TopMost.
I am hoping that there is a P/Invoke that I can do to get into the OS and say, "This Form On Top, NO MATTER WHAT".
The reason I am needing this is that I have an app that is occasio...
Suppose there is a c++ method int NativeMethod(double, double *) in a Native.dll. My first attempt at calling this method from managed code was (assuming I don't need to specify the entry point)
[DllImport("Native.dll")]
private static extern int NativeMethod(double inD, IntPtr outD);
Then to use the DLL I did
IntPtr x = Marshal.All...
Hi,
I'm developing an application using Visual Studios 2010 C# running on a Windows 7 Professional machine. In my application, I am trying to read the RSSI of a WLAN AP on a specific WiFi channel, regardless if my WLAN radio / bridge is connected to an AP or not.
I've search different forums and tried implementing sample codes that I f...
Hi,
I have below scenario:
WinForms app which allow only one instance of this app to be run (Mutex is in use here to check). App on start with some paramatere is runnig but hidden. When somebody will click on app again then Mutex will detect that app is already running and "unhide" the main form by call of native method (see method Brin...
Hi.
First, I know that it doesn't make sense to compare the dllimport attribute and the getProcAddress function directly. Rather, I am interested in comparing two pieces of code, that achieve basically the same thing - calling a function in a dll - by either importing the function with the dllimport attribute or with the getProcAddress ...
I have some code that I am using to update the amount of time the device will wait before going to sleep.
I update the registry and then try to tell the OS to reload the value, but it is not working. (The reload part does not work. The registry updates fine.)
I am going to post my code in the hopes that someone knows what I am doing ...
I've got some code which pinvokes native win32. Since I upgraded to .NET 4, the code started throwing a MethodAccessException saying:
Attempt by security transparent method 'Tek.Audio.Midi.MidiDevice.GetDevices()' to call native code through method 'Tek.Native.Windows.Multimedia.midiInGetNumDevs()' failed. Methods must be security crit...
I'm attempting to P/Invoke a C library from F#, and have encountered a peculiar issue. I have a module containing all my extern functions. The underlying C library has two functions with the same name, but different arguments. This, of course, is not allowed in an F# module.
module C =
open System.Runtime.InteropServices
[<DllImp...
I am using pinvoke to call functions from sslscan tool based on openssl;
I checked by hit and trial that where exception is occuring is due to memset.
It runs fine when i run it natively in VS.but using pinvoke causes this exception in c#.Its System.AccessViolation Exception.
These are the declarations:
struct sslCheckOptions options;...
I'd really like to listen for when a monitor gets hotplugged like when a laptop docs or has a external monitor plugged in.
I'm hoping I can do this in .net maybe with some pinvoke.
...