2013-05-06 62 views
3

我可以成功编译,但是当我去运行我的程序时,它会引发一个错误,告诉我一个DLL不存在。经过反复试验,我确定该程序正在寻找“ROGRAM FILES \ FolderName \ rrpd.dll”中的DLL,显然会切断文件夹的前四个字符。赋值语句删除字符

这是一个名为R & R Report Writer的应用程序,它已经存在了25年以上,从未遇到过这个问题。

调试,我确定错误来自于程序模块EXPLMGR.CPP赋值语句(显式库管理器):

CString CExplicitLibraryManager::FindLocalDllFile(CString csDllName) const 
{ 
ASSERT(csDllName.Find('\\') == -1); // These names should not have directory stuff. 
// Search for the file in the program directory directory. 
// If not found there, search in the registry system. 
// If not found in either location, just return the file name. 
CString csDllPath = m_csAppDirectory + csDllName ; 
BOOL bDllExists = DoesFileExist (csDllPath) ; // Don't bother calling DoesDllExist(). A path is provided. 
if (!bDllExists) 
{ 
    csDllPath = m_csRrSystemDirectory + csDllName ; 
    bDllExists = DoesFileExist (csDllPath) ; 
    if (!bDllExists) 
    { 
     // Must call the FindWindowsFile() here so that we can guarentee to return the full pathname. 
     csDllPath = FindWindowsFile (csDllName) ; 
     bDllExists = DoesFileExist (csDllPath) ; 
    } 
} 
if (bDllExists) 
{ 
    CFileStatus fsFile ; 
    CFile::GetStatus (csDllPath, fsFile) ; 
    //TRACE("CExplicitLibraryManager::FindLocalDllFile() Reports the DLL to be %s\n", fsFile.m_szFullName) ; 

    csDllPath = fsFile.m_szFullName ; 
} 
return csDllPath ; 
} 

具体而言,4号线向上从底部:

csDllPath = fsFile.m_szFullName ; 

此时,fsFile.m_szFullName是“C:\ PROGRAM FILES \ FolderName \ rrpd.dll”,csDllPath也是一样的。

调试和点击[F11],分配潜水右转入

c:\program files\Microsoft visual studio\vc98\mfc\src\strcore.cpp 

和部分是:

const CString& CString::operator=(LPCTSTR lpsz) 
{ 
ASSERT(lpsz == NULL || AfxIsValidString(lpsz)); 
AssignCopy(SafeStrlen(lpsz), lpsz); 
return *this; 
} 

立刻,如果我鼠标移到lpsz,它的价值现在是

"rogram files\FolderName\rrpd.dll" 

有什么办法可以解决这个问题吗?我可以提供哪些额外信息?

+1

我的第一个想法是重建所有,如果你还没有。 – RichieHindle 2013-05-06 21:42:47

+1

@RichieHindle说什么。这看起来像混合调试和非调试库的结果。 – jdigital 2013-05-06 21:46:42

+0

我已经在release和debug配置中重建了所有的东西。我不确定你的意思是关于调试/非调试库。 – 2013-05-07 11:07:02

回答

0

原来,在使程序与64位兼容的实验中,CFileStatus结构中的m_size元素从AFX.H文件中的LONG更改为ULONGLONG。这个问题在几个版本中处于休眠状态,但最后却爆发了。不知道为什么。无论如何,我将声明更改为LONG,现在看起来工作正常。

+1

Woah ...等一秒钟......你从** ULONGLONG'把**声明“返回”改为'LONG'? *请*告诉我你没有编辑'afx.h'文件! – 2013-05-07 22:39:47

+0

'CFileStatus :: m_size'长期以来一直是'ULONGLONG'(至少从VS 2003开始)。这听起来像你的程序可能链接到用VC6创建的库,其中该字段有一个'LONG'类型(我不确定VS 2002中该字段的类型 - 我无法说服该程序安装在我的Win7盒子上)。我认为你需要对整个程序/产品中使用的库进行一些分析。你当然不应该修补库头,不理解为什么他们似乎没有在你的构建中工作。 – 2013-05-08 08:17:28

+0

我们仍在使用VS98(VC++ 6) – 2013-05-09 16:54:39