com

How do I call .NET code (C#/vb.net) from vbScript?

笑着哭i 提交于 2019-12-03 07:52:42
问题 I imagine I can compile a C# DLL and then expose it as a COM object so that it can be CreateObject'd from VBscript. I'm just not sure the steps involved in doing this... 回答1: It can be very simple to do this. But there are a lot of places where it's not so simple. It depends a lot on what your class needs to be able to do, and how you intend to deploy it. Some issues to consider: Your class has to have a parameterless constructor. It can't expose static methods. Is deploying your COM DLL in

How to build a SAFEARRAY of pointers to VARIANTs?

戏子无情 提交于 2019-12-03 07:47:02
I'm trying to use a COM component with the following method: HRESULT _stdcall Run( [in] SAFEARRAY(BSTR) paramNames, [in] SAFEARRAY(VARIANT *) paramValues ); How can I create in C/C++ the paramValues array? Adding to the answers above for reference by future readers: In IDL, SAFEARRAY(...) means a pointer to an array descriptor. But in C++, SAFEARRAY means an array descriptor. So IDL's SAFEARRAY(...) is really C++'s SAFEARRAY * . This confused me to no end. To make things even more interesting, VB always passes arrays by reference. So VB's () As Long is SAFEARRAY<int32_t> ** in C++. (I don't

What is the closest thing to Windows COM/DCOM in the Linux world?

若如初见. 提交于 2019-12-03 07:32:35
问题 Anything higher-level, and more comprehensive than pipes/sockets? 回答1: Yes, there are lots of things, but there isn't one as "Standard" as COM/DCOM. At least, in Windows, COM / DCOM are used by "Windowsish" stuff, and other RPC mechanisms are used by un-"Windowsish" stuff. Linux doesn't have anything like that, instead things which need higher level RPC protocols typically use whatever their language provides, or a specific library which best suits an app's needs. Examples of that would be

How to diagnose cause, fix, or work around Adobe ActiveX / COM related error 0x80004005 progmatically?

爷,独闯天下 提交于 2019-12-03 07:25:49
I've built a C# .NET app that uses the Adobe ActiveX control to display a PDF. It relies on a couple DLLs that get shipped with the application. These DLLs interact with the locally installed Adobe Acrobat or Adobe Acrobat Reader installed on the machine. This app is being used by some customer already and works great for nearly all users ( I check to see that the local machine is running at least version 9 of either Acrobat or Reader already ). I've found 3 cases where the app returns the error message "Error HRESULT E_FAIL has been returned from a call to a COM component" when trying to load

How to embed .tlb as a resource file into .NET Assembly DLL?

流过昼夜 提交于 2019-12-03 07:22:37
问题 We're using our .NET Assembly DLL within native C++ through COM (CCW). Whenever I make new version of my DLL, I have to send two files (.dll and corresponding .tlb) to crew that's using it in their code. Is it possible to embed .tlb file as a resource in .NET DLL file? 回答1: It is not exactly straightforward to do this with Visual Studio .NET, but it can be done. At a basic level, what you have to do is this: Generate your TLB file, e.g., "YourLibrary.tlb". Create a Win32 resource script file

Delphi Spring DI: Is it possible to delegate interface instantiation without an implementing type?

隐身守侯 提交于 2019-12-03 07:12:56
I'm just getting started with the Delphi Spring Framework and was wondering whether the current version of the DI container somehow allows delegating the construction to a factory method without specifying an implementing type? E.g. something similar to this: GlobalContainer .RegisterFactory<ISomeObject>( function: ISomeObject begin Result := CreateComObject(CLASS_SomeObject) as ISomeObject; end) .Implements<ISomeObject> // could probably be implied from the above .AsSingletonPerThread; As you can see, my specific use case is the instantiation of COM objects. In that case the class

Expose dll for COM Interop

↘锁芯ラ 提交于 2019-12-03 07:05:12
I thought I knew how to do this, but obviously not so I'd appreciate some help! I can't get my dll to register so I can instantiate it in a VBS, or elsewhere. I wrote the following sample class, checked "Make assembly COM Visible", checked "Register for COM Interop", then built it. When I try to instantiate it from VBS I get the "Activex component can't create object" error. This is the class code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Smurf { public class Pants { public string Explode(bool Loud) { string result; if (Loud) result =

Does COM interop respect .NET AppDomain boundaries for assembly loading?

拈花ヽ惹草 提交于 2019-12-03 07:03:11
Here's the core problem: I have a .NET application that is using COM interop in a separate AppDomain. The COM stuff seems to be loading assemblies back into the default domain, rather than the AppDomain from which the COM stuff is being called. What I want to know is: is this expected behaviour, or am I doing something wrong to cause these COM related assemblies to be loaded in the wrong AppDomain? Please see a more detailed description of the situation below... The application consists of 3 assemblies: - the main EXE, the entry point of the application. - common.dll, containing just an

How does Visual Studio's debugger/interactive window dump the properties of COM Objects in .NET?

不羁岁月 提交于 2019-12-03 06:39:30
In this related question , I noted that Visual Studio's debugger is able to enumerate the properties of System.__ComObject references, which is "a hidden type used when the wrapper type is ambiguous" -- e.g., the type of object you get when you obtain it from another COM object and don't instantiate it yourself: Additionally, if you simply write a COM object's identifier into the Immediate Window, its properties and values are similarly dumped: Note that this is separate from VS2010's " Dynamic View ", which I believe uses IDispatch and COM reflection to enumerate the properties of COM objects

Class not registered error for Instantiation of C# object via COM from VC++

会有一股神秘感。 提交于 2019-12-03 06:27:18
In a VC++ project, I am trying to create an instance (via COM) of a C# class contained within a C# project. Facts Both the C# and C++ projects are compiled using .NET 4.0 The C# .dll is being registered using regasm /codebase "CSharpProjectName.dll" ", and windows command prompt reports, "Types registered successfully." In the c++ project, I attempt to create an instance of a class in the C# project, but I get an HRESULT of 0x80040154 - class not registered Here is an example of my attempt to create an instance of the .NET object from the C# .dll. The concrete class I am trying to instantiate