Questions tagged [interopservices]

84 questions
36
votes
6 answers

Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation

I am getting this error whenever I try and run a webjob project with application insight and entity framework. System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, …
Andrew
  • 2,571
  • 2
  • 31
  • 56
16
votes
0 answers

Modifying a C struct in VB.NET

I'm trying to use someone else's DLL coded in C in my VB.NET application. My VB.NET application sends some callbacks pointers to the DLL and DLL then calls back to functions inside my VB.NET application. The DLL is calling a function inside VB.NET…
Messias
  • 161
  • 3
5
votes
1 answer

Pass function pointer into a DLL from PowerShell

Problem I have a DLL with the following function exported. extern void Finalize(void (*WriteEntry)(const char* entry)); I am using P-Invoke to call into the DLL from PowerShell. In PowerShell scripts, I have a function WriteEntry defined, which I…
brandon_busby
  • 122
  • 11
5
votes
2 answers

What is IExpando and where is it used?

I was browsing the types in mscorlib using reflector (like you do...) and came across the IExpando interface, in the System.Runtime.InteropServices.Expando namespace. I did a search in reflector and even checked out MSDN, it seems that no types in…
fletcher
  • 13,380
  • 9
  • 52
  • 69
5
votes
1 answer

VBA array of User-Defined objects from a C# DLL

Background information: I'm building a SCADA system, which runs on VBA and I seek some of the powers of C#. I build a DLL library in C# and got basic data to flow between the DLL and VBA. [ComVisible(true),…
5
votes
2 answers

How do I use an unregistered dll from c#?

I have a custom dll (not registered) that I need to access via c#. How do I do this without registering the DLL? Edit: It is a C++ dll.
cabgef
  • 1,398
  • 3
  • 19
  • 35
5
votes
1 answer

Windows Service fails to start interactive process on user log on with WTSQueryUserToken for some versions of Windows

Following this link, I have implemented WTSQueryUserToken in my C# solution and called the CreateProcessAsUserWrapper.LaunchChildProcess("app_path") method from the OnStart of my Windows Service which is made to run as "LocalSystem". It is able to…
TrueD
  • 75
  • 2
  • 10
4
votes
1 answer

Interfacing with C/C++ routine in C# causes rip

I have a vendor's API call, which I want to use in my C# Windows Forms application. The problem is that no matter what P/Invoke I try, I get a crash on the line stating that the call has unbalanced the stack. I tried working with the vendor, but…
Sarah Weinberger
  • 15,041
  • 25
  • 83
  • 130
3
votes
1 answer

How to run bundled javascript files in blazor web assembly?

I have kept the bundled script files in wwwroot folder of blazor_wasm app. I added the file using script tags in index.html
3
votes
1 answer

Dynamic memory allocation in native dll

I have a native (unmanaged) .dll written in C++ that is to be called from a managed process (a C# program). When debugging the dll the problem I have has shown to be that when I create an object in the dll with the new keyword I get a System Access…
skitiddu
  • 31
  • 4
3
votes
1 answer

How to convert IntPtr to SafeHandle?

I have C# Windows service class: class MyService : ServiceBase { private void InitializeComponent() { //some other code ... SafeHandle sHandle = this.ServiceHandle; // I want to do this but this fails. …
Arnoj
  • 79
  • 8
3
votes
1 answer

GetWindowText() function is not executing correctly at all times

I'm writing a small application where I wish to get the URL from the Chrome browse. In order to first check if the Chrome browser is open or not I use the following code: IntPtr WindowTitleTextPtr = GetForegroundWindow(); StringBuilder…
HaggarTheHorrible
  • 7,083
  • 20
  • 70
  • 81
3
votes
2 answers

How convert const wchar_t* from C DLL to C# string automatically

It is just a curiosity. Perhaps there is a person in this world who did such things: I have to export C function and load it from C# code via DllImport const wchar_t * SysGetLibInfo() { return dllmanager.SysGetLibInfo(); } The best things to do…
Mnt DXM
  • 168
  • 1
  • 7
2
votes
2 answers

How to marshall as the I8 type with PInvoke?

I have a UInt32 value I want to pass to an external dll using InterOpServices. The prototype for the unmanaged code is: [DllImport("svr.dll")] public static extern UInt32 CreateTag ( [MarshalAs(UnmanagedType.LPStr)] String Name, Object…
bentaisan
  • 1,056
  • 3
  • 12
  • 29
2
votes
0 answers

'Invalid FORMATETC structure' C# while drag and drop

I am trying to convert the dataObject's data to CF_HDROP format when a drag operation starts. I was able to read the byteArray, which I will store at some point, but for now I am hard-coding the path to a file that actually exists on my drive. I…
1
2 3 4 5 6