I have a C API with the signature:
int GetBuffer(char* buffer, int* maxSize)
In C, I will call it this way:
char buffer[4096];
int maxSize = 4096;
GetBuffer(buffer, &maxSize);
maxSize is set to the buffer size, and set with the actual size filled.
I need to call it from C#. How do I do that under "safe mode"?
Thanks
...
Here is a C# program that tries Marshal.SizeOf on a few different types:
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
class AClass { }
[StructLayout(LayoutKind.Sequential)]
struct AStruct { }
[StructLayout(LayoutKind.Sequential)]
class B { AClass value; }
[StructLayout(LayoutKind.Sequent...
I am working on a C# application which opens Excel workbooks using Interop. It works fine except for one annoyance: when opening an Excel 2007 document on a machine using Excel 2003, a small message pops up saying "File conversion in progress". Does anyone know of a way to prevent that message from appearing at all?
...
I have an application I'm developing which closely mirrors Windows 7's Device Stage. In Device Stage, beneath the main banner there is a ListView containing actions embodied as ListViewItems.
In my WPF application, I used WindowsFormsHost to host a WinForms ListView so that I could use SetWindowTheme() on it and apply Windows Vista/7 st...
Hi there...
I have implemented a Kerberos server/client using sockets in Java, where the client sends his service-TGT to the server, and the server knows the client is authentic.
My main concern is the snooping 'man-in-the-middle' attack. Someone could capture the TGT, and pretend to be the client.
In a pure Java implementation, ...
We're going to have to write a C library and this library has to be accessible from Objective-C. Now I don't know anything about Objective-C so I wonder how simple Objective-C <-> C interoperability is. Is that as simple as including the C header in the Objective-C code and linking to the library? Is there anything special I'm supposed t...
We are manipulating our Word 2007 documents from .Net using Word Interop. Mostly doing stuff with fields as in:
For Each f In d.Fields
f.Select()
//do stuff with fields here
Next
This leaves the last field in the document selected.
So, for the sake of neatness we would like to positi...
I am using reading the documentation for app domains in .net 3.5 and came across SandboxInterop. The docs says
Gets or sets a value that indicates whether interface caching is disabled for interop calls in the application domain, so that a QueryInterface is performed on each call.
But why would I ever wish to disable the caching of Qu...
I have 2 applications; one is a ASP.NET 3.5 Ajax Application (Client) and the other is a WCF Web Application (BackEnd).
The applications are deployed in a separate Windows Server 2008 over IIS 7. The backend application has the net.tcp and http bindings enabled; some services are exposed under the netTcpBinding and other services are e...
Every few months I find myself needing to call Win32 from C#. Though I've done it a dozen times, I've usually forgotten the exact machinations, so I poke around the web or old code and figure out what DllImport statements I need, etc.
Am I alone?
Is there a sanctioned "Win32" class that has the requisite declarations for the entire Win...
I'd like to change the file name of the SaveFileDialog in the event handler attached to the FileOk event, in order to replace the file name typed in by the user with another file name in some cases, while keeping the dialog open:
var dialog = new SaveFileDialog();
...
dialog.FileOk +=
delegate (object sender, CancelEventArgs e)
...
I have to update a COM+ application to call a web service that uses WSE 3.0. What is the best way to call the web service from the COM+ client? My current plan is to create an Interop assembly like this:
COM+ Client <--> Interop Assembly <--> WSE 3.0 Web Service
Wondering if anyone has some guidance on best practices for this type of s...
I have the following C# code to launch an outlook window. The one think i want to add it to have certain part of the text bold and italics. how would i do that through this API?
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook...
How to return an array of C# strings (string[]) to unmanaged C++ code, and then use it from C++?
// Is it correct ???
[ComVisible(true)]
public string[] Foo()
{
return new string[] {"A", "B", "C"};
}
C++ code ??
...
I have a DLL, which is designed in C++, included in a C# project and I have strange AccessViolationExceptions happening unrationally. I suspect that my garbage isn't collected correctly. I have an unmanaged method apiGetSettings (from the DLL) which should copy data to a Settings object (actually a struct in the original code, but .NET I...
I'm having trouble accessing the some string fields in a COM interface. Calling the integer fields does not result in an error. When attempting call clientID(), deviceID() or key(), I get the old "Attempted to read or write protected memory" error.
Here is the source interface code: (code sourced from here)
[scriptable, uuid(fab51c92-9...
I'm working the open source library EasyHook.
What I'm trying to do, is hook into when a VB6 app calls CoCreateInstance from ole32.dll on a particular CLSID, return my own C# implementation for the object rather than the true COM object. My C# implementation derives from the same interface that tlbimp.exe spits out for the COM object I...
We have a COM component who’s implementation and interface definition exist in managed code but is driven by a native component. The managed component is returning a SafeArray back to the native code via the following method declaration.
interface IExample {
<return: MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_UNKN...
I have been working with .Net since VS2002 and since then any time that I had to work with COM or unmanaged code has been a pain. I've succeeded doing what was expected but almost always doing a trial-error procedure.
I've had enough of this and I want to know what's going on at the back room and understand how those things work.
As us...
Hello, I recently tried to combine SEAM and GWT in a project - but failed using GWT 1.7.1 and Seam 2.1.2 CR2 and Seam 2.2.0 GA (if you have any ideas why - here is the post).
I was wondering: Do you have any experiences which versions of GWT work with which version of SEAM out of the box? With workarounds?
Thx!
(PS: For Seam < 2.1.0 an...