com-interop

Releasing New Version of Tlb and When Tlb Needs To Be Re-Referenced

坚强是说给别人听的谎言 提交于 2020-07-09 07:16:45
问题 I have a C# dll and generarted a tlb using regasm. I have given a utility spreadsheet to the users which uses this tlb. The tlb is unregistered and registered (using regasm.exe) everytime a new version of our application is released. However, at times, when the user is using the spreadsheet after a new release, it throws a 'activex component cannot create instance' error, exactly on the line of code where I create an object of a type. I fix this just by, removing and adding the tlb reference

Setting an Enum property on a .NET object

岁酱吖の 提交于 2020-05-29 07:06:04
问题 Moving on from this question: Setting a "nullable" property on a .NET object Thanks to Olivier for his help so far. I am now using this import for the .NET type library: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/mscorlib_TLB.pas which is based on v4 of the CLR, as opposed to the antiquated version I was using. ..and I now have this code: procedure TDotNetObject.SetEnumProperty(const APropertyName: string; const AValue: OleVariant; const ATypeName: string; const AIndex:

Setting an Enum property on a .NET object

淺唱寂寞╮ 提交于 2020-05-29 07:02:05
问题 Moving on from this question: Setting a "nullable" property on a .NET object Thanks to Olivier for his help so far. I am now using this import for the .NET type library: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/mscorlib_TLB.pas which is based on v4 of the CLR, as opposed to the antiquated version I was using. ..and I now have this code: procedure TDotNetObject.SetEnumProperty(const APropertyName: string; const AValue: OleVariant; const ATypeName: string; const AIndex:

Setting an Enum property on a .NET object

对着背影说爱祢 提交于 2020-05-29 07:01:20
问题 Moving on from this question: Setting a "nullable" property on a .NET object Thanks to Olivier for his help so far. I am now using this import for the .NET type library: https://github.com/DelphiWorlds/MiscStuff/blob/master/Test/mscorlib_TLB.pas which is based on v4 of the CLR, as opposed to the antiquated version I was using. ..and I now have this code: procedure TDotNetObject.SetEnumProperty(const APropertyName: string; const AValue: OleVariant; const ATypeName: string; const AIndex:

Microsoft Excel Application entry is missing in DCOM Config

ぃ、小莉子 提交于 2020-04-11 04:34:29
问题 The entry for "Microsoft Excel Application" is not there in DCOM Config (tried in both 32-bit and 64-bit). How can I make it shows up there? I have Microsoft Office installed. 回答1: If you cannot find 'Microsoft Excel Application' in either 32-bit or 64-bit DCOMCNFG, you might go into registry to HKEY_CLASSES_ROOT/AppID and find the CLSID for your version of Excel (Excel 2013 has an AppID of {00020812-0000-0000-C000-000000000046}) Check that the (Default) REG_SZ for this key has a value set

Can Json.Net be embedded into the executable?

拥有回忆 提交于 2020-03-13 05:15:33
问题 I set the 'Embed Interop Types' property of the Netwonsoft.Json library to true and it returns an error: Cannot embed interop types from assembly 'c:\path\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll' because it is missing either the 'ImportedFromTypeLibAttribute' attribute or the 'PrimaryInteropAssemblyAttribute' attribute c:\path\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll It looks like looking for missing references within the Newtonsoft.Json library, but I

Where is the Wrapper Assembly Key File setting in VS 2008?

 ̄綄美尐妖づ 提交于 2020-02-20 10:39:38
问题 I'm trying to build an application that is strongly named. It is referencing a COM interop library that I add via the Add References dialog. It's been a while, but I seem to recall that in older versions of visual studio, there was a project setting for Wrapper Assembly Key File . I can't seem to find it in Visual Studio 2008? 回答1: I came across your post looking for the same thing, but found a different route on my own to get around the issue of strong naming a COM Interop referenced

IsAssignableFrom with COM

别说谁变了你拦得住时间么 提交于 2020-01-25 01:52:15
问题 I'm working with a COM-API, Autodesk Inventor. This test passes: [Test] public void CastTest() { Inventor.Document document = _application.ActiveDocument; var assemblyDocument = (Inventor.AssemblyDocument)document; Assert.NotNull(assemblyDocument); } This test fails: [Test] public void IsAssignableFromTest() { Assert.IsTrue(typeof(Inventor.Document).IsAssignableFrom(typeof(Inventor.AssemblyDocument))); } I don't know much about COM at all, is there a way to check if one COM type "inherits"

Reflection on COM Interop objects

China☆狼群 提交于 2020-01-22 20:02:26
问题 Trying to create a mapper for an Microsoft Office object to POCO's and found this // doesn't work // returns an empty array where o is a RCW on an office object foreach(var pi in o.GetType().GetProperties() ) tgt.SetValue(rc, pi.GetValue(o, null)); so have to resort to this foreach(var field in tgt.GetFields() ){ var pv = o.InvokeMember(field.Name, System.Reflection.BindingFlags.GetProperty, null, o, null); i.SetValue(rc, pv); } which works for now but wondering why the RCW.GetProperties()

Empty string becomes null when passed from Delphi to C# as a function argument

邮差的信 提交于 2020-01-21 09:20:37
问题 I have a native Delphi exe which calls into C# dll via COM interop. Here's the simplest case which demonstrate this issue: Delphi: IClass1 = interface(IDispatch) ['{B29BAF13-E9E4-33D7-9C92-FE28416C662D}'] function Test(const aStr: WideString): WideString; safecall; end; var obj: IClass1; s: string; begin obj := CoClass1.Create as IClass1; s := obj.Test(''); // Returns '[null]' end; C#: [ComVisible(true)] public interface IClass1 { string Test(string aStr); } [ComVisible(true)] public class