Compiling an IRtdServer Interface for Excel RTD() Function in .Net Core

%3CLINGO-SUB%20id%3D%22lingo-sub-863964%22%20slang%3D%22en-US%22%3ECompiling%20an%20IRtdServer%20Interface%20for%20Excel%20RTD()%20Function%20in%20.Net%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-863964%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20there%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20implement%20an%20IRtdServer%20interface%20for%20use%20by%20Excel%20in%20a%20.Net%20core%20project%3F%3C%2FP%3E%3CP%3EI%20have%20an%20existing%20.Net%204.6.1%20framework%20project%20which%20I%20am%20looking%20to%20upgrade%20to%20.Net%20Core%203.%26nbsp%3B%20I%20am%20using%20Visual%20Studio%202019%20Preview%2C%20version%203.0.100%20preview9%20of%20the%20.Net%20Core%203%20SDK%2C%20and%20C%23.%3C%2FP%3E%3CP%3EThe%20heart%20of%20this%20project%20is%20a%20class%20to%20communicate%20with%20Excel%20using%20Excel%E2%80%99s%20RTD%20function%3A%3C%2FP%3E%3CP%3E%5BGuid(%222B70D74D-A4F6-485F-8CDF-4CE514E75183%22)%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5BProgId(%22Ameritrade.RTD%22)%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5BComVisible(true)%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20public%20class%20RtdQuoteServer%20%3A%20IRtdServer%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%3CP%3ETo%20create%20the%20interface%20for%20the.Net%20Framework%20project%2C%20I%20use%20the%20following%3A%3C%2FP%3E%3CP%3E%25SystemRoot%25%5CMicrosoft.Net%5CFramework64%5Cv4.0.30319%5CRegAsm.exe%20%25~dp0%5CAmeritradeRtd%5Cbin%5CDebug%5CAmeritradeRtd.dll%20%2Fcodebase%3C%2FP%3E%3CP%3EThis%20works%20fine%20for%20the%20.Net%20framework%20version.%26nbsp%3B%20I%20have%20ported%20the%20application%20to%20.Net%20core%2C%20but%20have%20been%20unable%20to%20get%20it%20to%20work.%3C%2FP%3E%3CP%3ERunning%20RegAsm%20against%20the%20.Net%20core%20dll%20generates%20the%20following%20error%3A%3C%2FP%3E%3CP%3Eregasm%3A%20error%20RA0000%20%3A%20could%20not%20load%20file%20or%20assembly%20System.Runtime%2C%20version%3D4.2.1.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Db03f5f7f11d50a3a'%20or%20one%20of%20its%20dependencies.%26nbsp%3B%20The%20system%20cannot%20find%20the%20file%20specified.%3C%2FP%3E%3CP%3EI%20found%20this%20article%2C%20indicating%20that%20creating%20COM%20components%20is%20now%20supported%20in%20.Net%20Core%203.0%20-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fcore%2Fnative-interop%2Fexpose-components-to-com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fcore%2Fnative-interop%2Fexpose-components-to-com%3C%2FA%3E%3C%2FP%3E%3CP%3EI%20have%20attempted%20to%20register%20the%20DLL%3A%3C%2FP%3E%3CP%3Eregsvr32%20%22C%3A%5CProjects%5CDEC%20Decision%20Capital%5CARTHyperion%5CAmeritradeRtdCore%5Cbin%5CDebug%5Cnetcoreapp3.0%5CAmeritradeRtdCore.comhost.dll%22%3C%2FP%3E%3CP%3EThis%20gives%20three%20different%20results%20on%20three%20different%20PCs%3A%3C%2FP%3E%3CP%3E1)%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20413px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132678iDA7A5D49662E4F61%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Regsvr32.png%22%20title%3D%22Regsvr32.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E2)%3C%2FP%3E%3CP%3ENo%20error%20is%20displayed%2C%20but%20the%20registration%20doesn%E2%80%99t%20work.%3C%2FP%3E%3CP%3E3)%3C%2FP%3E%3CP%3EThe%20registration%20succeeds%2C%20however%20the%20underlying%20issue%20remains%2C%20i.e.%20I%20can%E2%80%99t%20get%20Excel%20to%20communicate%20with%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20greatly%20appreciated.%3C%2FP%3E%3CP%3EGeoff%20Olding%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-863964%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Visitor

Hello there

Is it possible to implement an IRtdServer interface for use by Excel in a .Net core project?

I have an existing .Net 4.6.1 framework project which I am looking to upgrade to .Net Core 3.  I am using Visual Studio 2019 Preview, version 3.0.100 preview9 of the .Net Core 3 SDK, and C#.

The heart of this project is a class to communicate with Excel using Excel’s RTD function:

[Guid("2B70D74D-A4F6-485F-8CDF-4CE514E75183")]

    [ProgId("Ameritrade.RTD")]

    [ComVisible(true)]

    public class RtdQuoteServer : IRtdServer

    {

To create the interface for the.Net Framework project, I use the following:

%SystemRoot%\Microsoft.Net\Framework64\v4.0.30319\RegAsm.exe %~dp0\AmeritradeRtd\bin\Debug\AmeritradeRtd.dll /codebase

This works fine for the .Net framework version.  I have ported the application to .Net core, but have been unable to get it to work.

Running RegAsm against the .Net core dll generates the following error:

regasm: error RA0000 : could not load file or assembly System.Runtime, version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.  The system cannot find the file specified.

I found this article, indicating that creating COM components is now supported in .Net Core 3.0 - https://docs.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com

I have attempted to register the DLL:

regsvr32 "C:\Projects\DEC Decision Capital\ARTHyperion\AmeritradeRtdCore\bin\Debug\netcoreapp3.0\AmeritradeRtdCore.comhost.dll"

This gives three different results on three different PCs:

1)

Regsvr32.png

2)

No error is displayed, but the registration doesn’t work.

3)

The registration succeeds, however the underlying issue remains, i.e. I can’t get Excel to communicate with it.

 

Any help greatly appreciated.

Geoff Olding

0 Replies