好汉救急(附几行代码,关于FTP功能的) - 调用Debug版本的DLL提示"Debug Assertion Failed!"发布Release版本的DLL提示LNK4089异常
好汉救急!(附几行代码,关于FTP功能的) - 调用Debug版本的DLL提示"Debug Assertion Failed!...",发布Release版本的DLL提示LNK4089错误.
代码如下
----StdAfx.h---------------------------------------------
...
#include <afxinet.h>
//(因提示重复引用, 故没有引用windows.h)
...
----TestFTP.cpp------------------------------------------
#include "stdafx.h "
CInternetSession g_FTPsession;
CFtpConnection* g_FTPpConn;
__declspec(dllexport) int __stdcall FTP_Open( const char *ip, const char *user, const char *passwd )
{
if(g_FTPpConn != NULL){
FTP_Close();
}
try{
g_FTPpConn = g_FTPsession.GetFtpConnection(ip, user, passwd);
}catch(...){
return -1;
}
if( g_FTPpConn != NULL )
return 1;
return GetLastError();
}
Question #1 - 这是作一个FTP功能的DLL封装, Release版本的DLL函数被调用时不出错,但编译时提示如下, 如何解决? ( 20分 )
LINK : warning LNK4089: all references to "ADVAPI32.dll " discarded by /OPT:REF
LINK : warning LNK4089: all references to "SHELL32.dll " discarded by /OPT:REF
LINK : warning LNK4089: all references to "comdlg32.dll " discarded by /OPT:REF
Question #2 - 编译Debug版本的DLL时无出错提示, 但调用该函数时弹出错误提示 "Debug Assertion Failed!... ", 如果将函数体中的内容comment out, 然后只写一行 "return 100 ", 则在调用时不弹出错误, 这问题如何解决? ( 30分 )
------解决方案--------------------
CFtpConnection* g_FTPpConn 没有初始化。CFtpConnection* g_FTPpConn = NULL;
------解决方案--------------------
初始化有问题,msdn查查CInternetSession CFtpConnection的构造
代码如下
----StdAfx.h---------------------------------------------
...
#include <afxinet.h>
//(因提示重复引用, 故没有引用windows.h)
...
----TestFTP.cpp------------------------------------------
#include "stdafx.h "
CInternetSession g_FTPsession;
CFtpConnection* g_FTPpConn;
__declspec(dllexport) int __stdcall FTP_Open( const char *ip, const char *user, const char *passwd )
{
if(g_FTPpConn != NULL){
FTP_Close();
}
try{
g_FTPpConn = g_FTPsession.GetFtpConnection(ip, user, passwd);
}catch(...){
return -1;
}
if( g_FTPpConn != NULL )
return 1;
return GetLastError();
}
Question #1 - 这是作一个FTP功能的DLL封装, Release版本的DLL函数被调用时不出错,但编译时提示如下, 如何解决? ( 20分 )
LINK : warning LNK4089: all references to "ADVAPI32.dll " discarded by /OPT:REF
LINK : warning LNK4089: all references to "SHELL32.dll " discarded by /OPT:REF
LINK : warning LNK4089: all references to "comdlg32.dll " discarded by /OPT:REF
Question #2 - 编译Debug版本的DLL时无出错提示, 但调用该函数时弹出错误提示 "Debug Assertion Failed!... ", 如果将函数体中的内容comment out, 然后只写一行 "return 100 ", 则在调用时不弹出错误, 这问题如何解决? ( 30分 )
------解决方案--------------------
CFtpConnection* g_FTPpConn 没有初始化。CFtpConnection* g_FTPpConn = NULL;
------解决方案--------------------
初始化有问题,msdn查查CInternetSession CFtpConnection的构造