System.Runtime.InteropServices.ComAwareEventInfo is not found

System.Runtime.InteropServices.ComAwareEventInfo is not found

Hello all,

I'm using integration studio to integrate to a 3rd party application.

They provided some dlls that I have added as a reference in VStudio 2010.

I'm also adding the reference in the project :

using System.Runtime.InteropServices;

whenever I try to use any of the methods provided by their API, when I build the project I get the following message :

The type 'System.Runtime.InteropServices.ComAwareEventInfo' is not found, and is required to embed interop types. Are you missing an assembly reference?
If I remove from the code, any call to the API methods, the project builds with success
Just to add a few more information.

I created a new Vstudio 2010 Project, type Class Library, and added the references to the 3rd Party dlls.

Copied the code from the Integration Studio version and it works, no errors on Build.

In Integration Studio, Options :

.NET IDE :  C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
.NET Compiler Tool : C:\windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
.NET CT Options : /nologo /verbosity:minimal /target:Rebuild /property:Configuration=Release

Hi Nelson,

ComAwareEventInfo is a 4.0+ class, so you either have your project targeted at the wrong framework or VS2010 is messing the build up.
First confirm that on the project properties it is set to either ".NET Framework 2.0", ".NET Framework 3.5".
If it is:
  • right click on the project -> Unload Project"
  • right click on the project -> "Edit .."
  • Set the ToolsVersion to "4.0"
  • Save and close the file
  • right click on the project "Reload Project"
Now this is a bit trial and error, for VS2010 the correct ToolsVersion is "4.0" so if it was already set to that you can also try to reduce it to "3.5" or "2.0", but last time I tried VS2010 had lots of bugs with that.

By the way you also get that error then just doing Publish in Integration Studio or just when compiling in VisualStudio?

João Rosado
Hi again,

All the settings are Ok, but remember that even when using a MSBuild 4.0 you will not be able to use a framework 4.0 dll in a extension.
I recomend reducing the .Net Compiler Tool to the 3.5 version just to avoid strange problems.

João Rosado
On Publish I get the error :

 Could not locate the .NET Framework SDK.  The task is looking for the path to the .NET Framework SDK at the location 
 specified in the SDKInstallRootv2.0 value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework.  
 You may be able to solve the problem by doing one of the following: 
 1.) Install the .NET Framework SDK. 
 2.) Manually set the above registry key to the correct location.

I'm trying to install .Net 4 SDK but I'm getting an error also.
Hi Nelson,

That is a warning, not an error. It's normal to have that warning.
Try to scroll the error a bit more.

João Rosado
Maybe this is the one :

Wrapper.cs(26,13): error CS0246: The type or namespace name 'Interop' could not be found 
(are you missing a using directive or an assembly reference?)
Wrapper.cs(26,52): error CS0246: The type or namespace name 'Interop' could not be found
 (are you missing a using directive or an assembly reference?)