dllimport

Using DLLImport to import an Object

I have a dll for a c++ class (SLABHIDDevice.dll). I am trying to use the functions of this dll in a C#.net application. The dll contains several methods which I can use easily with statements such as this... (I appolagize if i get some of the terminology wrong here I am new to using dlls) [DllImport("SLABHIDDevice.dll")] publi...

How to load a C# dll in python?

Hello, how can I load a c# dll in python? Do I have to put some extra code in the c# files? (like export in c++ files) I don't want to use IronPython. I want to import a module to Python! ...

When loading a dll in Python does the dir function shows its methods?

Does this code shows the methods from a dll? from ctypes import * x = cdll.LoadLibrary("olari.dll") dir(x) if not, how can we see the .dll methods in python? ...

Dynamically load .dlls from network share not browsable on client PC -- WCF?

I'm architecting a WPF application using the PnP Composite Application Guidance. The application will be run locally, within our intranet. Modules will be loaded dynamically based on user roles. The modules must therefore be accessible to the application through a network share, thus accessible from the client machines. What I'd like t...

Calling a custom type from a DLL written in C++ from c#

I'm using a DLL written in c++ in my C# project. I have been able to call functions within the DLL using this code: [DllImport("hidfuncs", EntryPoint = "vm_hid_scan", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr VmHidScan(); Now I need to call a functi...

How can Find all dependencies of an application?

In a Portable-Exe ,there is possibilities to find the imported section ,and also all imported dll names (using import descriptor).Here Ex, One application Exe has many imported dlls(kernel32,advapi,user,comctl32....etc),Now i want to find all dependencies in that app exe(imported dlls)..give me the logic using recursive function calling....

need help custom marshaling..??

Hi, i need help about custom marshaling..i have a native DLL..the parameters of the some DLL functions is defined with unsigned char* for example; typedef short apiStatus; apiStatus __declspec(dllexport) __stdcall DrfGetFirmwareVersion (HANDLE hCom, unsigned char *major,unsigned char *minor, unsigned char ReaderAddr = 0xff); t...

Help me convert C++ structure into C#

Hello, I am completely new to C#, and need help converting a C++ structure to C#. The C++ structure is given as: #define QUE_ADDR_BUF_LENGTH 50 #define QUE_POST_BUF_LENGTH 11 typedef struct { const WCHAR *streetAddress; const WCHAR *city; const WCHAR *state; const WCHAR *country; const WCHAR *postalCode; } QueS...

how to use <DllImport in VB.net?

Hi, how should I DLLImport thing in VB.NET? Example would be: <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function GetWindowText(ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer End Function If I put it inside a Class or somewhere else, I get "DLLimport ...

unmanaged c++ dll called from c#, crashes when CString used in dll

Hello Most excellent Stackoverflowians Using visual studio 2008 Team System, I have a c++ dll (mfc statically linked regular dll) which has a simple function extern "C" __declspec(dllexport) int MyExportedFunction( ) { AFX_MANAGE_STATE(AfxGetStaticModuleState( )) CString tempString ; .... } The DLLImport from the c# applica...

need to call non exported functions of DLL

Hello, I need to call(get) non exported functions of DLL. Unlike PE export table, non exports do not have any table having entries for these. More over all disassembler like IDAPro and other debuggers only show exported function names with decorated names(After Shift+F3 incase of IDA) and show all other functions like sub_000FF sorts of...

Retrieving dll version info via Win32 - VerQueryValue(...) crashes under Win7 x64

The respected open source .NET wrapper implementation (SharpBITS) of Windows BITS services fails identifying the underlying BITS version under Win7 x64. Here is the source code that fails. NativeMethods are native Win32 calls wrapped by .NET methods and decorated via DllImport attribute. private static BitsVersion GetBitsVersion() ...

PInvokeStackImbalance when including a C DLL into C#

I have written a C DLL and some C# code to test including this DLL and executing functions from it. I am not too familiar with this process, and am receiving a PInvokeStackImbalance exception whenever my DLL function is called from the C# source code. The code is as follows (I have commented most code out to isolate this problem): C# In...

What happens when I DllImport a function that is not available on the runtime platform?

I previously asked, How to determine the target of a symbolic link or Reparse Point? ...and got an answer that suggested the use of the Win32 function GetFinalPathNameByHandle, a function first available on Vista. What happens if I build the .NET Assembly and then attempt to run it on WinXP, or WS2003, which does not have the GetFin...

Unmanaged DLL (exporting Dialog) + Class Library (DLL) + no Windows Style/Themes

Hi, I have a managed application TestApplication.exe in C# and Application.EnableVisualStyles() is allready called. I have a Class Library MySharedCode.dll also in C# which uses [DLLImport()] to import some External dialogs out of an unmanaged dll. Well, now I am using (add reference) MySharedCode.dll in my TestApplication.exe and cal...

DllImport Unmanaged, Non .NET Dll to .NET Project Representing Char * and Void __StdCall

I have a DLL non .net and unmanaged written in Borland C++ that I need to import. It returns void and has the identifier __stdcall on the function. It also requires passing of char *. When I try to add it as a reference to my project in VS 2005, it returns an error of not valid assembly. How can I do this in C#? This what I currently ...

Pointers in C# to Retrieve Reference From DllImport Function

I am referencing a DLL in my C# project as follows: [DllImport("FeeCalculation.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] public static extern void FeeCalculation(string cin, string cout, string flimit, string frate, string fwindow, string fincrement, string fbird, ...

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt" DllImporting C#

I am getting this weird error while trying to marshal data to my DLL function and back to the C# code. I don't see where I am passing null or reading invalid memory and this error is so vague. Any clues?? Code below: The FeeCalculation function is exported as follows in the DLL: extern "C" __declspec(dllexport) void __stdcall FeeCalc...

C# Struct No Parameterless Constructor? See what I need to accomplish

I am using a struct to pass to an unmanaged DLL as so - [StructLayout(LayoutKind.Sequential)] public struct valTable { public byte type; public byte map; public byte spare1; public byte spare2; public int par; public int min; public byte[...

C#: Access 32-bit/64-bit DLL depending on platform

Hi, we use a self-written 32bit C++ DLL from our C# applications. Now we've noticed that when the C# applications are run on a 64bit system, the 64bit runtime is automatically used and of course the 32bit DLL can not be accessed from the 64bit runtime. My question is: is there a way of using the 32bit DLL? If not, if I created a 64bit ...