dllimport

Finding the class name of the On-Screen Keyboard?

I am attempting to use this code sample to control the Windows XP On-Screen Keyboard (OSK.exe) from a C# (.NET 3.5) Winforms application: [DllImport("User32.dll")]public static extern Int32 SetForegroundWindow(int hWnd); [DllImport("user32.dll")]public static extern int FindWindow(string lpClassName, string lpWindowName); private void...

dynamically running a DLL at a remote Windows box?

Hello All, Is there a way of dynamically running a DLL at a remote Windows box? Say a user wants to send a his own DLL file to a remote server and run a function in that DLL at the remote site. The user may be able to provide function entry points as well as required parameters, but no more. (e.g. no header file) I am thinking of se...

P/invoke System.ExecutionEngineException when passing array as ref/out

Im using an P/invoke on an unmanaged dll function swe_calc_ut. int swe_calc_ut(double tjd_et, int ipl, int iflag, double *xx, char *serr) Parameter xx is meant to be an "array of 6 doubles for storing the result", and parameter serr a "character string to return error messages" my c# code is as follows. [DllImport("swedll32.dll")]...

pInvoke C# DLLimport problem

Im using P/invoke on an unmanaged dll function swe_get_planet_name() in C#. The given function definition is, char* swe_get_planet_name(int ipl, char *spname); This means the return value is assigned to char *spname? It seemed so from the sample code in the documentation. char snam[40]; /* * get the name of the planet p ...

Dynamically binding a DLL function with unknown return types and parameters

Hello All, This question is related to my previous question - http://stackoverflow.com/questions/3632473/dynamically-running-a-dll-at-a-remote-windows-box First of all, thanks for all your helpful insights. I have found a way to run a DLL at a remote machine. Now what I am trying to do is as follows. (1) send a DLL to the remote m...

trouble using unmanaged c++ from c# using dllimport

Hi guys, i am having trouble importing c++ unmanaged dll into C# [winform]. Can someone help? Basically i am just trying to create a safearray of strings in c++ and trying to send it to C#. Here is my c++ code. extern "C" __declspec(dllexport) BOOL GetStringArr(SAFEARRAY* arr) { SAFEARRAY* myArray; SAFEARRAYBOUND rgsabound[1]; ...

COM dll is not being flushed out

Guys, I am interacting with a custom COM component called CSCCOM in my c# project. I am wrapping it with IDisposable as below: Form1.cs try { using (CSCCOMWRAP CSC = new CSCCOMWRAP()) { CSCCodeList CSCL = new CSCCodeList(CSC); comboBox1.DataSource = CSCL.List; Marshal.ReleaseComObject(CSCL); } } catc...

C#: How do I dynamically load/instantiate a DLL?

I've seen a couple examples out there that could possibly help me, but I don't have that much time to explore them as I just found out today that my bosses have to demo this a week earlier than planned, and I want to add this new functionality. I'll try and keep this short and sweet. Ok, this is like my 10th time trying to right this t...

Dynamically Loading DLLs at Runtime

I'm working on a C# application that supports two communications interfaces, each supported by its own DLL. Each DLL contains the same function names, but their implementation varies slightly depending on the supported interface. As it is, users will typically have only one DLL installed on their machine, not both. The DLL for the old...

C# P/Invoke on CUDA DLL eventually causes AccessViolationException

This is driving me crazy. I've looked all over, but I'm not sure I understand exactly what's causing this error. I'm making a call to a DLL (that I've coded as a separate project) which runs a CUDA kernel on some data I'm using. Although, I suspect the issue isn't being caused by CUDA, since the code has been tested and works at least ...

Linking error LNK2019 in MSVC, unresolved symbols with __imp__ prefix, but should be from static lib.

Hi all, I'm running into linking problems in MSVC for a project that I wrote for g++. Here's the problem: I build libssh as a static library as part of my application, adding the target in cmake with add_library(ssh_static STATIC $libssh_SRCS) Libssh is in C, so I have 'extern "C" {...}' wrapping the includes in my c++ sources. I then...

DllImport incomplete names

I am using several P/Invokes under .NET. However, I want my library to work both in Windows and Linux, preferably with the same binaries. Since the native library I depend on is available on multiple platforms, I was hoping to just have them along with my managed library's binaries. Right now I'm using something like this: [DllImport(...

C# wrapper design for DLL with P/Invoke

I need an opinion on writing a managed (C#) wrapper for an unmanaged C++ DLL. Let's say I have an object like this: public class ManagedObject { public void DoSomethingWithTheObject() { } } and suppose that the DoSomethingWithTheObject() method has to make a call to the unmanaged DLL method. Now there are two acceptable poss...

how to track dlls being loaded into a process?

I am looking for a tool to trace the dlls being loaded into a process on windows. The app i have is loading managed and unmanaged dlls, but not sure if the managed ones are loading the unmaanged ones. Process Explorer and File Explorer doesn't seem to help much. Any thoughts?? thanks!! ...

DLL Get Symbols From Its Parent (Loader)

I am porting a program to MS Windows. This program uses dynamically loaded plugins. The plugins reference symbols in the main program. I cannot even get the DLLs past the linker without all symbols being resolved. Is there a way to solve this? ...

.Net SerialPort still locked after application is killed

I have an application which calls SerialPort.Open() ... This works fine and data is read/written through the port. However if a user decides to kill the Application through the TaskManager the application will close without calling my destructor calling SerialPort.Close(). This in turn (only sometimes) causes the following error: Acces...

Generate C# DLLImport declarations from a native dll

Do you know a soft which automatically generates C# code (with [DllImport] attributes in .cs) from a native DLL in order to use this DLL in a C# code? ...

Linker error with debug build with different compiler versions

Hello, We have a DLL, built with MS Visual Studio 2010, in release mode. We provide this DLL to different customers, along with a .lib file. The functions in the DLL are exported with: extern "C" __declspec(dllexport) int analyze(int id); Our customers have two applications that makes use of this DLL. Both of these applications im...

Need to activate a window

I have a situation like this. I have the window handle of an application. I need to activate it. I tried all these functions but is not working always.(most of the time , it doesn't work the first time and I'll have to manually click on it to activate it. Second attempt onwards it works fine) The reason why I am doing this is because I ...

DllImport generates System.DllNotFoundException

Hello, I’m having some difficulties while trying to consume an unmanaged-code dll from my application (Written in C# framework 4.0) I’m using the dll import as follows [DllImport(@"C:\MGW_SDK.dll", EntryPoint = "fInicializaSDK")] public static extern int fInicializaSDK(); The weird thing is that when called from my development enviro...