locked
How do you use Embed Interop Types in C# ?

    Question

  • Hi,

    I installed VS 2010 RC version and migrated a VS 2008 C# Windows Forms application of ours.  I'd like to try out the Embed Interop Types feature to see if we can go without needing to distribute referenced PIAs (we have a lot of them!).  I've seen some posts and samples about embedding Microsoft Office PIAs, but what I am interested in is seeing if we can embed type information from our own PIAs. 

    The first thing I noticed was that I didn't see the Embed Interop Types property in the Properties pane when any of our PIAs are selected in Solution Explorer.  I recall seeing some posts elsewhere saying that the Embed Interop Types feature is the default compile option so I compiled the app without changing anything.  The app is currently targeted to x86 because the PIAs are Win32.  

    The application runs, but not without the PIAs (I tried both debug and release versions).  The app immediately crashes when I attempt to run it after I deleted the PIAs (this is the same behavior as with VS 2008.  (I know we need to distribute the PIAs with VS 2008.) 

    Is there anything else I can try or am I misunderstanding something? 

    Thanks! 
    Denny

    Saturday, January 16, 2010 3:09 AM

All replies

  • New info: If I create a new Windows Forms app (tried both VB and C#) and browse for a PIA, I see the Embed Interop Types property in the property grid when the PIA is selected.  I would like to see this property in the migrated C# VS 2008 app, but it is not there even when I drop the reference and re-add it.  How can I see the EIT property in the migrated app? 
    Tuesday, January 19, 2010 8:46 PM
  • OK, I think I found the reason why it does not show the EIT property -- because the app is still targeted to the 3.5 Framework even though I changed it to Framework 4 (or thought I did).  When I attempt to change the target Framework to 4 or Client 4, it closes the app and reopens it, but I didn't know it didn't actually change it because it reopened the solution without the Properties being displayed and there was no error message so I thought the Framework change was successful. 

    If I attempt to change the target Framework from 3.5 to 4, it closes the app, reopens it and it is still 3.5.  If I attempt to change the target Framework from 3.5 to Client 4, it closes the app, reopens it and it is then Client 3.5.  So now the question is how can I change the migrated app to target Framework 4? 

    Tuesday, January 19, 2010 9:07 PM