锁定数组 Com 异常
Locked Array Com Exception
我在线程的 API 方法中使用数组时遇到问题。
锁定数组无效。
Thread thrCreate = new Thread(createThread);
thrCreate.SetApartmentState(ApartmentState.STA);
thrCreate.Start();
private void createThread()
{
IEdmAddCustomRefs2 pdmRefs = (IEdmAddCustomRefs2)vault2.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs);
IEdmFile5 pdmRefFile = (IEdmFile5)pdmResult;
int[] iRefCount = new int[1];
iRefCount[0] = 1;
string[] strRefPath = new string[1];
strRefPath[0] = strPDFPath + strSerName + ".pdf";
lock (strRefPath)
{
lock (iRefCount)
{
pdmRefs.AddReferencesPath2(pdmRefFile.ID, ref strRefPath, ref iRefCount);
}
}
}
调用 COM 异常 DISP_E_ARRAYISLOCKED。
我现在正在使用 AddReferences 方法,我不再收到异常。
这是更新后的代码:
Thread thrCreate = new Thread(createThread);
thrCreate.SetApartmentState(ApartmentState.STA);
thrCreate.Start();
private void createThread()
{
IEdmAddCustomRefs2 pdmRefs = (IEdmAddCustomRefs2)vault2.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs);
IEdmFile5 pdmRefFile = (IEdmFile5)pdmResult;
string[] strRefPath = new string[1];
strRefPath[0] = strPDFPath + strSerName + ".pdf";
pdmRefs.AddReferencesPath(pdmRefFile.ID, ref strRefPath);
}
我在线程的 API 方法中使用数组时遇到问题。
锁定数组无效。
Thread thrCreate = new Thread(createThread);
thrCreate.SetApartmentState(ApartmentState.STA);
thrCreate.Start();
private void createThread()
{
IEdmAddCustomRefs2 pdmRefs = (IEdmAddCustomRefs2)vault2.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs);
IEdmFile5 pdmRefFile = (IEdmFile5)pdmResult;
int[] iRefCount = new int[1];
iRefCount[0] = 1;
string[] strRefPath = new string[1];
strRefPath[0] = strPDFPath + strSerName + ".pdf";
lock (strRefPath)
{
lock (iRefCount)
{
pdmRefs.AddReferencesPath2(pdmRefFile.ID, ref strRefPath, ref iRefCount);
}
}
}
调用 COM 异常 DISP_E_ARRAYISLOCKED。
我现在正在使用 AddReferences 方法,我不再收到异常。
这是更新后的代码:
Thread thrCreate = new Thread(createThread);
thrCreate.SetApartmentState(ApartmentState.STA);
thrCreate.Start();
private void createThread()
{
IEdmAddCustomRefs2 pdmRefs = (IEdmAddCustomRefs2)vault2.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs);
IEdmFile5 pdmRefFile = (IEdmFile5)pdmResult;
string[] strRefPath = new string[1];
strRefPath[0] = strPDFPath + strSerName + ".pdf";
pdmRefs.AddReferencesPath(pdmRefFile.ID, ref strRefPath);
}