com-interop

warning MSB3391: <DLL> does not contain any types that can be unregistered for COM Interop

不问归期 提交于 2019-12-01 03:44:57
I've made a simple C# DLL (that's part of a much larger project) using VS2005. I need to use the DLL in Excel via VBA code so I am using COM Interop on the assembly. I am trying to make the build process automatically generate the necessary TLB file so that I don't need to go to the command line and use regasm after every build. My problem is that although the DLL compiles and builds fine, it does not generate a TLB file. Instead, the error in the title prints out in the output box. I've gotten other DLLs to build TLB files by going to the project's properties in VS2005 -> Build -> Output ->

What is this `Object[*]` type I get with COM interop?

青春壹個敷衍的年華 提交于 2019-12-01 03:39:27
I do C# excel interop. I call macros from C#, and I expect arrays of objects. I'm able to get 2-dimensional arrays of objects from the macros which returns 2-dimensional arrays. However, an other (third party) macro is supposed to return a one-dimensional array. I can't get the (object[])xlApp.Run(...) working (it throws an exception), and the type info in the debugger says the result is of type Object[*] . The actual message from the exception is Unable to cast object of type 'System.Object[*]' to type 'System.Object[]'. What is this Object[*] type and how do I retrieve a one-dimensional

Is a COMException of 0x80040154 always 'Class not registered'?

这一生的挚爱 提交于 2019-12-01 03:38:22
问题 Does a System.Runtime.InteropServices.COMException of 0x80040154 always mean that the class isn't registered? I'm getting a COMException which says "Retrieving the COM class factory for component with CLSID {29131539-2EED-1069-BF5D-00DD011186B7} failed due to the following error: 80040154." It's trying to load Interop.Domino.dll which is a reference I got from the COM tab of Add Reference called "Lotus Domino Objects" which points to domobj.tlb in the Notes program folder. I wrote the code

Convention for passing BSTRs into COM functions from C# (COM interop)

﹥>﹥吖頭↗ 提交于 2019-12-01 03:33:22
I am writing writing an API in COM in C++, and also writing a program which consumes this API in C#. My question is about BSTR memory management semantics when passing BSTRs into COM functions. Say my IDL looks like: HRESULT SomeFunction([in] BSTR input); Currently this function is implemented like this: HRESULT SomeFunction(BSTR input) { // Do stuff ..., then: SysFreeString(input); } When I call it from C# with something like SomeFunction(myString) , will C# generate something like this (pseudocode): myString = SysAllocString("string"); SomeFunction(myString); Or rather like this: myString =

Passing string array from VB6 to C#.net

安稳与你 提交于 2019-12-01 02:12:12
问题 How to pass a VB6 string array [Assume, s =Array("a", "b", "c", "d")] to C#.Net through COM Interop? I tried to implement passing C# string array to VB and VB string array to C# as below C#->VB working fine but other way (VB=>C#) giving a compile error called "Function or interface marked as restricted, or the function uses an automation type not supported in visual basic" . My code below C# public interface ITest { string[] GetArray(); void SetArray(string[] arrayVal ); } public class Test :

How to CreateObject in C#?

别说谁变了你拦得住时间么 提交于 2019-12-01 01:10:16
I want to translate the following VB6 code into C# If optHost(0).Value Then Set m_oScpiAccess = New IcSCPIActiveX.IcSCPIAccess Else sHost = txtHost.Text Set m_oScpiAccess = CreateObject("Exfo.IcSCPIActiveX.IcSCPIAccess", sHost) End If I used TlbImp.exe to create wrappers for the COM classes, and I tried: if (string.IsNullOrEmpty(host)) { // this works IcSCPIAccess = new IcSCPIAccess(); } else { // throws MissingMethodException IcSCPIAccess = (IcSCPIAccess)Activator.CreateInstance( typeof(IcSCPIAccessClass), host); } But there is no constructor which accepts the host parameter It is not a

What is this `Object[*]` type I get with COM interop?

笑着哭i 提交于 2019-11-30 23:44:48
问题 I do C# excel interop. I call macros from C#, and I expect arrays of objects. I'm able to get 2-dimensional arrays of objects from the macros which returns 2-dimensional arrays. However, an other (third party) macro is supposed to return a one-dimensional array. I can't get the (object[])xlApp.Run(...) working (it throws an exception), and the type info in the debugger says the result is of type Object[*] . The actual message from the exception is Unable to cast object of type 'System.Object[

what is the advantage of .net4's new no pia feature [deploying PIA's]

独自空忆成欢 提交于 2019-11-30 22:59:59
Its possibly im just missing something here but, when I write some code for Excel interop, here is how it goes. I add a reference to the Excel Com libraries. VS creates a PIA - Microsoft.Office.Interop.Excel....(via tlbimp right?). I copy the exe and the interop(PIA) dll to any machine (with .net) and it works? Is there a scenario where I would have to deploy/register the PIA? Or have I got something wrong here, because it seems to me embedding the PIA into the main assembly doesn't seem like a great big feature? Please excuse my ignorance, if any. Update: So I did some tests, I wrote an app

.NET Interop: Find All instances of of a running COM object with C#

安稳与你 提交于 2019-11-30 22:43:19
Background I am automating some Office application (Word and PowerPoint) via command-line tool. One thing my tool needs to do is locate all the running instances of Word. I know how to get a reference to one of the instances... Object running_obj = null; { running_obj = System.Runtime.InteropServices.Marshal.GetActiveObject(progid); } catch (System.Exception) { //failed to find the object; } if (running_obj!=null) { var running_obj_type = System.Type.GetTypeFromProgID(progid); Microsoft.Office.Interop.Word.Application running_obj_wrapper; running_obj_wrapper = (Microsoft.Office.Interop.Word

Is it possible to register a .NET assembly for COM interop without adding registry entries?

若如初见. 提交于 2019-11-30 21:18:12
I am deploying a .NET VSTO application via click once. The application's main assembly needs to be registered for COM interop as part of the installation process. I know that this can be done by writing code to execute "REGASM assembly.dll /tlb", but the problem is that the target workstations that will be installing my application don't have administrative rights, so the regasm fails when trying to register the type library. My question is, how can I register my .net assembly for com interoperability when I don't have administrative access? You could use registration-free activation of COM