6

I have got lots of warnings like this one and I have not got a clue what they mean.

Does anyone know what this is?

"At least one of the arguments for 'IOleWindow.GetWindow' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate."

I should also point out that it relates to "c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets"

Henrik
  • 23,186
  • 6
  • 42
  • 92
James
  • 2,812
  • 3
  • 22
  • 33
  • I removed VBIDE which has cleared some of the warnings. I'm not sure why VBIDE was included in the references. – James May 23 '12 at 10:42
  • do you still have problems of the same? – kenny May 23 '12 at 10:52
  • 1
    Yes I do still get some warnings of the same. I have a number of COM objects, I may have to build a test project to try and identify which of these COM objects cause the issue. Maybe I should be marking some of my methods or fields as unsafe? – James May 23 '12 at 10:56
  • This warning is not "weird" this warning is exactly what you would suspect. You are using a COM object that requires a pointer, which by default in C# is unsafe code, I don't understand the confusion. If you want to avoid this then use P/Invoke on the Win32 library instead. – Security Hound May 23 '12 at 11:22
  • Ok, so I have found the culprit. I had a rouge 'Acrobat Access 3.0 Type Library' in my project. I have removed it and the warning have gone. I am not sure when or why this was added but it is not required. The main problem with the warning message is that it only indicates the project not the COM in question. – James May 23 '12 at 11:30
  • Possible duplicate of http://stackoverflow.com/questions/269063/lots-of-build-warnings-when-com-objects-activeds-or-msxml2-are-referenced/1402834#1402834 – Ed Bayiates Jul 06 '16 at 20:10

3 Answers3

2

You can use Type Library Importer (tblimp) to import the DLL outside Visual Studio and use the generated reference instead of letting Visual Studio create it, hence removing the warnings.

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
  • Great answer. That way you only see the warnings once. Especially handy when treating warnings as errors, and it also makes it easier to reuse the assembly. – Wade Hatler Feb 19 '14 at 21:57
1

Nice explanation of situation can be found here:

You can safely ignore these warnings. You can find out more about this issue by consulting this page: http://msdn.microsoft.com/en-us/library/aa289520%28v=vs.71%29.aspx

The "In/Out C-Style Arrays" section is particularly relevant. Bottom-line : if the returned buffer of the specified methods in the warnings were accepting "in" values, you would have to apply the modifications in the article. But since all the listed methods only handle out buffers, the warnings are of no consequence to you nor the framework.

However, if you want to permanently get rid of the warnings (when you do a "Rebuild All" for instance), you will have no choice to proceed as described in the article. You will have to disassemble the interop wrapper (with ildasm), edit the IL and reassemble (with ilasm). This process is also called "creative round tripping".

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Petr Abdulin
  • 33,883
  • 9
  • 62
  • 96
0

The main problem with the warning message is that it only indicates the project not the COM in question so a process of elimination seems to be the only way to track this down.

James
  • 2,812
  • 3
  • 22
  • 33