Perhaps it just doesn't like the format. Maybe it would work better if you replaced:
ReferencedDocumentDescriptors(1).ReferencedFileDescriptor
with
ReferencedDocumentDescriptors.Item(1).ReferencedFileDescriptor
Or to break it down even further:
Dim oInvApp As Inventor.Application = GetObject(,"Inventor.Application")
Dim oDrawDoc As Inventor.DrawingDocument = oInvApp.ActiveDocument
Dim oNewModelFile As String = "C:\Temp\OtherFile.iam"
Dim oDDs As Inventor.DocumentDescriptorsEnumerator = oDrawDoc.ReferencedDocumentDescriptors
Dim oDD As Inventor.DocumentDescriptor = oDDs.Item(1)
Dim oFD As Inventor.FileDescriptor = oDD.ReferencedFileDescriptor
oFD.ReplaceReference(oNewModelFile)
oDrawDoc.Update()
Sorry, I'm not as familiar with C# as I am with VB.NET, but here's my attempt at the C# version of this code:
Inventor.Application oInvApp = GetObject(,"Inventor.Application");
Inventor.DrawingDocument oDrawDoc = oInvApp.ActiveDocument;
String oNewModelFile = "C:\Temp\OtherFile.iam";
Inventor.DocumentDescriptorsEnumerator oDDs = oDrawDoc.ReferencedDocumentDescriptors;
Inventor.DocumentDescriptor oDD = oDDs.Item(1);
Inventor.FileDescriptor oFD = oDD.ReferencedFileDescriptor;
oFD.ReplaceReference(oNewModelFile);
oDrawDoc.Update();
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield

(Not an Autodesk Employee)