My project builds with MSBuild 4 but not with MSBuild 3.5 even though I'm targeting the same version of the .NET Framework (3.5)?

邮差的信 提交于 2019-12-04 12:44:07

It looks like InitializeClientContextFromStringSid has an optional parameter in the specification. Though MSBuild in .Net Framework 4.0 supports the use of optional parameters in C# by allowing you to leave them out of the function call, previous versions of the MSBuild do not support this approach. So you must to supply the parameter even if it's not being used when building with older version of the Framework.

HRESULT InitializeClientContextFromStringSid(
  [in]            BSTR SidString,
  [in]            LONG lOptions,
  [in, optional]  VARIANT varReserved,
  [out]           IAzClientContext **ppClientContext
);

The same issue is happening with the GetRolesmethod.

From my understanding, the reason you can build using the 4.0 version of MSBuild and target 3.5 Framework is that the CLR already supported the use of Optional parameters, for example VB.NET has always supported them. However, when using MSBuild 3.5, it is going to use the older rules/specification that did not allow support for Optional parameters in C# and thus will give you build errors.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!