My KeyCommands.cs model uses these two references...
using Bentley.MstnPlatformNET.InteropServices; using Bentley.Interop.MicroStationDGN;
Both are necessary because of this..
Application app = Utilities.ComApp; app.CadInputQueue.SendCommand("mdl unload AppName", true);
The C# compiler is unhappy. It tells me this...
1>CSC : warning CS1762: A reference was created to embedded interop assembly 'Bentley.Interop.MicroStationDGN, Version=8.0.0.0, Culture=neutral, PublicKeyToken=4bf6c96a266e58d4' because of an indirect reference to that assembly created by assembly 'Bentley.MicroStation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4bf6c96a266e58d4'. Consider changing the 'Embed Interop Types' property on either assembly.
It's a warning, so I can ignore it. But ignoring warnings, experience tells me, can lead to trouble. As far as I can see there's nought I can do about it. What's Bentley's view on Bentley.MicroStation and Bentley.Interop.MicroStationDGN and the Embed Interop Types property in those assemblies?
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Jon Summers
Unknown said:Embed Interop Types has to be switched off for all referenced MicroStation assemblies.
Correct.
Bob
Unknown said:Embed Interop Types has to be switched off for all referenced MicroStation assemblies
I checked the references and found that Bentley.MstnPlatformNET.InteropServices had embedded turned on, so I turned it off and all is well. No other Bentley reference had embedded turned on.
Bentley.MstnPlatformNET.InteropServices
Why does that happen? Is there a way to prevent it happening?
Regards, Jon Summers LA Solutions
Hi Jon,
Unknown said:Why does that happen?
Because it's the default behavior of Visual Studio and it solve a specific issue with Primary Interop Assemblies. I recommend to read following articles:
This approach / feature is not used when developing MicroStation addins using COM Interop, so for as the most important information is "switch it off" ;-)
Unknown said:Is there a way to prevent it happening?
I am not sure if it's hardcoded in Visual Studio or whether it can be changed. But I don't treat it as an issue, because you have to check any referenced assembly and to Copy Local to False anyway, so to modify also Embed Interop Type to False, especially if it's relevant for InteropServices assembly only is no extra work. And it's set once for every project.
With regards,
Jan