com-interop

COMException (0x80010108 - RPC_E_DISCONNECTED) When Closing Excel.Workbook

When I run the following code, I get the exception below: ''# NOTE: ExcelApp is a Private main form variable Dim ReportBooks As Excel.Workbooks = ExcelApp.Workbooks Dim ReportBook As Excel.Workbook = ReportBooks.Open(localFilename) Dim ReportSheet As Excel.Worksheet = ReportBook.Sheets("Report") ''# Retreive data from sheet ReleaseCOM...

How can I tell if an ADODB::_RecordsetPtr has already been created?

I am trying to write a class that uses ADO to retrieve SQL records. The intent is for the class to maintain one private recordset an other methods move forward, retrieve fields, etc. This is a basic example of my class: class SqlADO { private: ADODB::_RecordsetPtr _recordset; public: void Open(); //open the connection vo...

Pass Binary Data from VBScript to .Net

I have a classic asp page which allows a user to upload a file. I can retrieve the binary content of the file (verified this matches the original file exactly) but then I need to pass the data to a COM Visible .Net assembly. The data is marshaled across as a string object but when I decode it using the Unicode encoding there is some data...

UnauthorizedAccessException in ComRegisterFunction when accessing registry on Win 7 64.

I have a [ComRegisterFunction] that I am using to register a BHO Internet explorer extension. During registration on 64-bit windows 7 machines, a UnauthorizedAccessException is thrown on the call to subKey.SetValue("NoExplorer", 1). The registry appears to have BHO's located @ \HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersio...

How to share session cookies between Internet Explorer and an ActiveX components hosted in a webpage?

I am currently working on a .Net application which makes HTTP requests to some web applications hosted on a IIS server. The application is deployed through ClickOnce and is working fine on simple networks architectures. One of our customers has a very complex network involving a custom authentication server on which the user has first to...

Encrypting using RSA via COM Interop = "The requested operation requires delegation to be enabled on the machine."

Hi Guys, So i've got this little static method in a .Net class which takes a string, uses some stored public key and returns the encrypted version of that key. This is basically so some user entered data can be saved an encrypted, then retrieved and decrypted at a later date. Pretty basic stuff and the unit test works fine. However, ...

Fastest way to access VB6 String in C#

I am using COM Interop. I have a call in VB6 which returns a string of roughly 13000 chars. If I execute the call in pure VB6 it takes about 800ms to execute. If I execute it via c# and COM Interop it takes about 8 seconds. I'm assuming the delay is caused by marshaling. If I am correct about marshaling, I'd be grateful if someone coul...

C# Class Library wont register for COM

Hello All, I am trying to gain access to a .NET class library in Microsoft Excel. To do this I know that the .NET class library must be registered with COM. So I tried going to my Assembly Info and Setting COM Visible to true. Then on the build tab I set Register for COM Interop for true also. I checked the AssemblyInfo.cs file and it do...

Converting C++ string/wchar_t* to C# string ?

Question: I need to call a C# dll from a C++ executable. I use COM, and it works fine for int, long and bool. But I can't get a string along... The IDL file says it's a BSTR, but I can't pass it correctly, and neither retrieve one. I tried using wchar_t* and using sysalloc as I did with VB6, but that doesn't seem to work. Anybody knows...

When does the .NET runtime hold a reference count > 1 for COM objects?

Until recently, I believed that the .NET runtime only increases the reference count of COM objects by 1 when creating a runtime-callable wrapper, and that only one such runtime-callable wrapper is created for any given COM object. If I'm not mistaken, the above implies that Marshal.FinalReleaseComObject and Marshal.ReleaseComObject do t...

Accessing underlying managed object through a COM interface

I have a third party assembly with a public abstract class implementing a certain COM interface. Something to the effect of [ComVisible(true)] public abstract class SomeClass: ISomeInterface { .... public void Method1() {...} } The actual object is an internal object extending the SomeClass and is instantiated by the third party c...

INetCfgComponent::RaisePropertyUi arguments

I'm trying to do some COM interop and attempting to invoke the INetCfgComponent::RaisePropertyUi method. I've gotten to the point where I can enumerate devices and get a valid INetCfgComponent for the adapter that I want to display the UI for. However, I'm a COM newbie (let alone COM interop) so I have no idea what the third argument in...

COM Interop - Wait for Excel to Complete Operation

Hello, I am doing some COM Interop work with Excel and other Office Automation Software. A Co-Worker has mentioned to me that I need to wait for these Automation Servers to become ready after issuing a command to them. I, however, cannot see the purpose of this as don't all calls block until the automation server completes the given ...

How do i transfer this unmanaged code from asp to asp.net 2/mvc?

hi guys, i'm a newbie to ASP.net interop features, so what i have right here is some unmanaged dll that i need to call from my asp.net mvc app. the dll name is CTSerialNumChecksum.dll. i can easily call the dll from asp using just those two lines below and from my trusty response. write everything is working fine. set CheckSumObj = Ser...

Returning S_FALSE from a C# COM dll

I have a method defined in IDL as follows : interface IMyFunc : IDispatch { [id(1), helpstring("method GetNextFunction")] HRESULT GetNextFunction( [in,out] long* lPos, [out, retval] BSTR* bstrName); } Using C++ I always implemented this as follows : STDMETHODIMP CMyFunc::GetNextFunction(long *nID, long *lPos, BSTR *bstrNa...

COM Interop between 32 bit and 64 bit applications

I have a .NET windows forms application compiled as x86 – it needs to be compiled as x86 because it references 3rd party DLLs which are 32 bit. The application uses COM interop to automate Office applications and also AutoCAD. My question is: will my COM interop code work okay on a 64 bit operating system against the 64 bit versions of O...

Enumerate list of COM interface implemented through C# COM Interop

I'm querying an MFC implemented COM object that is implemented as follows: class CA : public MfcComLib::IA { ... }; class CB : public MfcComLib::IB { ... }; class ATL_NO_VTABLE CExposedCoClass : public CComObjectRootEx<CComSingleThreadModel>, public CA, public CB { public: BEGIN_COM_MAP(CExposedCoClass ) COM...

midl.exe cannot load mscorlib.tlb

I'm trying to use midl to turn an idl file into a tlb. However, when I try I get this warning: warning MIDL2015: failed to load tlb in importlib : mscorlib.tlb and I then get a subsequent error: error MIDL2337 : unsatisfied forward declaration : _Object..... I'm certain that the error is due to the first warning. I've tried the same ...

Workflow Foundation (WF) -- Why does setting a DependencyProperty to a COM object using SetValue() throw an ArgumentException?

Assume that I have a .NET Workflow Foundation (WF) SequenceActivity class with the following "output" property: public IWorkspace Workspace { get; private set; } // ^^^^^^^^^^ // important: this is a COM interface type! public static DependencyProperty WorkspaceProperty = DependencyProperty.Register( "Workspace", ...

Using ref Array parameters in C# with COM interop

I have a 3rd party COM libary that I'm consuming and am having problems with array parameters. The method signature that I'm calling is as follows: int GetItems(ref System.Array theArray) The documentation says that the method's return value is the number of items it will populate into the array, but when it get's called, all of the ...