ExcelDna icon indicating copy to clipboard operation
ExcelDna copied to clipboard

Investigate Edit-and-Continue vs. PIA Embed-Interop-Types

Open govert opened this issue 6 years ago • 5 comments

I think edit-and-continue does not work for methods that use an embed-interop-types COM class. That means if we disable embed-interop-types we have a much better edit-and-continue experience.

We should check and document this if true. (also https://github.com/dotnet/roslyn/wiki/EnC-Supported-Edits)

We might try to figure out if we can disable the options for debug builds only. That might be a suitable default if not too disruptive.

govert avatar May 26 '18 21:05 govert

http://www.vbforums.com/showthread.php?839513-Change-quot-Embed-Interop-Types-quot-for-a-reference-from-a-compiler-directive

govert avatar Apr 03 '19 11:04 govert

I was able to reproduce it just now on an Excel-DNA v1.1 add-in targeting .NET 4.8, using VS2019

image

Setting Embed Interop Types to False on the assemblies included by ExcelDna.Interop makes Edit-and-Continue work again, as you mentioned :tada:

image

augustoproiete avatar Jul 30 '20 00:07 augustoproiete

I think your idea of disabling Embed Interop Types automatically for Debug builds is the way to go.

One easy approach could be to add a tiny build target to take care of that, and bundle it with the ExcelDna.Interop package - targeting the specific assemblies in this package, but might not be as effective if the user has references to other primary-interop-assemblies or even direct COMReferences in the project.

A more effective (but more complex) approach might be be adding a build target in the ExcelDna.AddIn that enumerates all references, and sets Embed Interop Types=False for all assembly references and COMReferences when building in Debug (even if assembly is not a PIA).

augustoproiete avatar Jul 30 '20 00:07 augustoproiete

One needs to be a bit careful here - some features of the COM interop with C# are only enabled when the PIA is embedded. So some of the syntax of COM calls that are allowed would no longer be supported if you switch off the embedding (I think some of the type conversions, or indexed property magic - can't remember). So I'm not sure it would be a backward compatible change, or even always desired. Sadly there's a messy trade-off here for C#, but as far as I know not for Visual Basic.

govert avatar Jul 31 '20 20:07 govert

Some of the syntax of COM calls that are allowed would no longer be supported if you switch off the embedding

In that case it doesn't seem like we have a good solution for this yet.

augustoproiete avatar Aug 01 '20 15:08 augustoproiete