ExcelDna
ExcelDna copied to clipboard
Investigate Edit-and-Continue vs. PIA Embed-Interop-Types
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.
http://www.vbforums.com/showthread.php?839513-Change-quot-Embed-Interop-Types-quot-for-a-reference-from-a-compiler-directive
I was able to reproduce it just now on an Excel-DNA v1.1 add-in targeting .NET 4.8, using VS2019
Setting Embed Interop Types
to False
on the assemblies included by ExcelDna.Interop
makes Edit-and-Continue work again, as you mentioned :tada:
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 COMReference
s 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 COMReference
s when building in Debug (even if assembly is not a PIA).
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.
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.