VS 2010 B 2 - Warning CS1762 when building solution with C# and F# projects - by fwoolz

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


6
0
Sign in
to vote
ID 523944 Comments
Status Closed Workarounds
Type Bug Repros 4
Opened 1/8/2010 10:18:15 AM
Access Restriction Public

Description

Note that this is related to a previous bug report.

Scenario:

I have a solution with two C# projects and one F# project where one of the C# projects references the F# project. Both the C# project and the referenced F# project have direct references to a COM .dll file since a reference to the associated .tlb file won't let itself be added to the F# project.

When the solution is built, the following warning is generated:

------ Rebuild All started: Project: Specifyx, Configuration: Debug Any CPU ------
warning CS1762: A reference was created to embedded interop assembly 'c:\Program Files (x86)\Sparx Systems\EA\Interop.EA.dll' because of an indirect reference to that assembly created by assembly 'c:\Users\fred\Documents\Visual Studio 2010\Projects\Specifyx\Backend\bin\Debug\Specifyx.Backend.dll'. Consider changing the 'Embed Interop Types' property on either assembly.

Specifyx is the C# project; Specifyx.Backend.dll is the assembly generated by the F# project.

If the reference in the C# project is change so that Embed Interop Types = false, the build fails with the following errors:

C:\Users\fred\documents\visual studio 2010\Projects\Specifyx\Specifyx\Connector.cs(145,40): error CS0266: Cannot implicitly convert type 'object' to 'EA.Package'. An explicit conversion exists (are you missing a cast?)
C:\Users\fred\documents\visual studio 2010\Projects\Specifyx\Specifyx\Connector.cs(146,40): error CS0266: Cannot implicitly convert type 'object' to 'EA.Package'. An explicit conversion exists (are you missing a cast?)

CS1762 isn't listed in the VS2010 B2 help, BTW. Also, F# references don't provide an option to embed interop types.
Sign in to post a comment.
Posted by Denise at OTI on 8/11/2011 at 8:19 AM
I'm having a similar situation. I have a solution with two VisualBasic projects. One is MainOPAddIn and the other one is OPBootAddIn. OPBootAddIn references both MainOPAddIn and Office (office.dll). Office is set to EIT=true and MainOPAddIn is set to EIT=false. I get the error "A reference was created to embedded interop assembly 'office' because of an indirect reference to that assembly from assembly 'MainOPAddIn'. Consider changing the 'Embed Interop Types' property on either assembly." I cannot set EIT=True on MainOPAddIn because there's a sub in there that does not lend itself to creating an interface.

What can I do now? I really do need to have EIT=true for Office so that we can deploy the code to work on either Office 2007 and Office 2010 without having to also distribute the PIAs.
Posted by GearWorld on 7/20/2010 at 10:56 AM
How do you set VS2010 to have the Embed Interop Type to false by default ?
Cause mine is always True each time I add a COM library and I always have to set it to false.

C#
VS2010

Thank you very much
Posted by paintballbob on 6/28/2010 at 5:03 AM
I also had this problem in VS2010 when working on a WPF project targeted at .net 4. To fix the warnings I set the "Embed Interop Types" property to false on Accessibility.dll. This makes all of the warnings go away.
Posted by Microsoft on 3/2/2010 at 5:51 PM
Thanks for reporting this issue you've encountered with Visual Studio 2010!

You are correct that F# does not have the Embed Interop Types feature, and so if your C# and F# components will be referencing both each other and the same COM assembly, then you'll need to turn Embed Interop Types off in the C# project. It sounds like you found this setting yourself.

As for the CS0266 errors you saw afterwards, it sounds like your C# 4.0 code had previously worked without explicit casts because Embed Interop Types imports methods and properties of type object as if they have type dynamic to allow late-binding, as you'd see talking to COM libraries in VBA. By turning off Embed Interop Types, you'll need to add an explicit cast to EA.Package, as suggested by the CS0266 error. This cast would have also been required in C# 3.0 (VS2008) and will be required here if you've opted out of our updated COM support (i.e. have Embed Interop Types off for that COM reference).

Alex Turner
Program Manager
Visual C# Compiler
Posted by VS Ov on 3/2/2010 at 6:13 AM
Oooops! Finally found 'Embed Interop Types' proprty (it was right before my eyes all time long!), set it to false and warnings are gone...

Thanks
Victor

P.S. I don't think it's a workaround for original problem - I did not have F# project in the mix.
Posted by VS Ov on 3/2/2010 at 6:08 AM
Similiar case, but without F#. Three projects in solution. RdoHelper project uses interop assembly RedemptionNetSN.dll. MailRepDirLib refer to RdoHelper, eRepMeetingSyncService refer to MailRepDirLib.
Both MailRepDirLib and eRepMeetingSyncService use RedemptionNetSN.dll directly and reference to RedemptionNetSN.dll added to both projects.
Two warnings are generated:

warning CS1762: A reference was created to embedded interop assembly 'd:\Projects\Beta2010\Common\RdoHelper\RdoHelper\RedemptionNetSN.dll' because of an indirect reference to that assembly created by assembly 'd:\Projects\Beta2010\MailRepDir\Src\MailRepDirLib\bin\Debug\MailRepDirLib.dll'. Consider changing the 'Embed Interop Types' property on either assembly.
warning CS1762: A reference was created to embedded interop assembly 'd:\Projects\Beta2010\Common\RdoHelper\RdoHelper\RedemptionNetSN.dll' because of an indirect reference to that assembly created by assembly 'd:\Projects\Beta2010\Common\RdoHelper\bin\Debug\RdoHelper.dll'. Consider changing the 'Embed Interop Types' property on either assembly.

BTW, I could not find 'Embed Interop Types' property anyware...

Thank you
Victor
Posted by Roy Procops on 2/4/2010 at 8:19 AM
Following up on previous report... somehow references to accessibility and PresentationUI assemblies got added to my csharp project. I can't explain how that happened, but it was the source of the warning 1762 (and we always treat warnings as errors).

Sorry for the spurious commentary. I'm investigating how those references might have gotten added.

Roy
Posted by Roy Procops on 2/4/2010 at 7:58 AM
I'm also suddenly seeing the 1762 error in a simpler case involving WPF.

A reference was created to embedded interop assembly 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Accessibility.dll' because of an indirect reference to that assembly created by assembly 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\PresentationFramework.dll'. Consider changing the 'Embed Interop Types' property on either assembly.    error CS1762

I'm not entirely sure what to do about this error, or why it suddenly appeared.

January LCTP 3
Posted by Microsoft on 1/10/2010 at 11:54 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you