Well, solved it. I was using my own ComWrapper, not the one provided by SDK. When declaring COM interfaces in .NET, you cannot simply pick and choose what methods you want. All the methods needed to be declared, and it needs to be in order.
COM Interfaces cannot include any interfaces in their base interface list, and they must declare the interface member functions in the order tht the methods appear in the COM Interface. COM interfaces declared in c# must include declarations of all the members of their base interfaces with the exception of members of IUnknown and IDispatch..dotnet framework automatically adds these!
Thanks
"snnair" wrote:
[Quoted Text] > Hi > > I am trying to add attribute to media metadata. But when this interface > function is called, it throws an exception saying Value exceeds the expected > range. > > The code I wrote is as below > bool AddAttrib(string pwszFileName, ushort wStreamNum, StringBuilder > pwszAttribName, WMT_ATTR_DATATYPE wAttribType, string pwszAttribValue, ushort > wLangIndex) > { > ushort wAttribIndex = 0; > uint nValueLength = (uint)((pwszAttribValue.Length + 1) * 2); > byte[] pbValue = new Byte[nValueLength]; > pbValue[nValueLength - 2] = 0; > pbValue[nValueLength - 1] = 0; > > iwmheaderinfo3 header; > IWMMetadataEditor2 metaDataEditor; // = null; > > try > { > WindowsMediaWrapper.CreateEditor(out metaDataEditor); > metaDataEditor.Open(pwszFileName); > header = (iwmheaderinfo3)metaDataEditor; > > header.AddAttribute( > wStreamNum, > pwszAttribName, > out wAttribIndex, > wAttribType, > wLangIndex, > pbValue, > nValueLength); > > } > catch (Exception ex) > { > Console.WriteLine(ex.Message + ex.StackTrace); > return (false); > } > metaDataEditor.Flush(); > metaDataEditor.Close(); > > return (true); > } > > The wStreamNum and wLangIndex is passed as 0x0 and 0 resp. > > Does anybody have any idea, what is wrong there which i am doing. > Thanks in advance. > >
|