C++ OPENSSL 中PEM_read_bio_RSAPrivateKey 返回NULL 求教呀 5C

测试程序中的,先调用公钥加密,然后调用私钥解密。公钥加密publi是1,私钥解密publi 是0.
RSA* createRSA(unsigned char*key,int publi)
{
RSA *rsa= NULL;
BIO*keybio;
keybio= BIO_new_mem_buf(key, -1);
if(keybio==NULL)
{
printf("Failed to create key BIO\n");
return 0;
}
size_t nSize = BIO_ctrl_pending(keybio);
if(publi)
{
rsa = PEM_read_bio_RSA_PUBKEY(keybio, &rsa,NULL, NULL);
}
else
{
rsa= PEM_read_bio_RSAPrivateKey(keybio, &rsa,NULL, NULL);
}
if(rsa== NULL)
{
printf("Failed to create RSA\n");
}
return rsa;
}
PEM_read_bio_RSA_PUBKEY 返回值正常
PEM_read_bio_RSAPrivateKey 返回值是NULL
第一次接触,在网上找了很多都没得结果.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
为什么 GetVolumeInformation("C:\\",NULL,NULL,&VolumeSerialNumber,NULL,NULL,NULL,NULL); 怎么返回负数呀?
DWORD VolumeSerialNumber;rnGetVolumeInformation("C:\\",NULL,NULL,&VolumeSerialNumber,NULL,NULL,NULL,NULL); rn 怎么返回负数呀?
老大们???GetVolumeInformation("C:\\",NULL,NULL,&VolumeSerialNumber,NULL,NULL,NULL,NULL); 怎么返回负数呀???
老大们???GetVolumeInformation("C:\\",NULL,NULL,&VolumeSerialNumber,NULL,NULL,NULL,NULL);rn 怎么返回负数呀???
openssl中使用PEM_read_bio_RSAPrivateKey读取私钥,获取的结构体RSA为NULL,请问是什么情况?
path = [[NSBundle mainBundle] pathForResource:@"private_key" ofType:@"pem"];rn //path = [[NSBundle mainBundle] pathForResource:@"client" ofType:@"key"];rn char *p_de;rn RSA *p_rsa;rn FILE *file;rn int rsa_len;rn rn if ((file = fopen([path UTF8String], "r")) == NULL) rn perror("\nopen key file error");rn rn //RSA_read_bio_RSAPrivateKey 使用bio读取密钥rn BIO *key = NULL;rn p_rsa = NULL;rn rn //新建一个文件结构体rn key = BIO_new(BIO_s_file());rn rn BIO_read_filename(key, [path UTF8String]);rn rn //读取key文件中的私钥保存在RSA结构体中rn p_rsa = PEM_read_bio_RSAPrivateKey(key, NULL, nil, nil);rn rn if(!p_rsa)rn ERR_print_errors_fp(stdout);rn return nil;rn rn
求教:数据库返回NULL时
在SqlServer2000的数据库中rnrn库中EMP表有:ParentId int(4)列.允许存空值的,rn在数据集返回时,处理到这处就有异常,rnrn请问:如何将返回的NULL,转换成""呀.rn.NET中用什么来表示返回的是NULL呀.rnrn很感谢大家一直以来对偶的帮助.rnrn偶的QQ:80671382.rn每天晚上都有空的.rn凡有CSDN字样的QQ验证,一律通过.
为什么我的bean总是返回null呀?
代码为:rnpackage checkUser;rnrnimport pub.dbBean;rnimport java.sql.*;rnrnpublic class checkUserBean rn public checkUserBean()rn rn public String checkUser(String userName,String userPass)rn rn String checkInfo="";rn if(userName!="")rn tryrn dbBean dbo=new dbBean();rn String sql="SELECT * FROM foa_WebPurview WHERE f_UserName='"+userName+"'";rn ResultSet rs=dbo.executeQuery(sql);rn if (rs.next()) rn sql="SELECT * FROM foa_WebPurview WHERE f_UserName='"+userName+"' AND f_UserPass='"+userPass+"'";rn rs=dbo.executeQuery(sql);rn if (rs.next()) rn checkInfo="userok";rn rn else rn checkInfo="密码输入错误!";rn rn rn elsern checkInfo="用户名不存在!";rn rn rn catch(Exception e)rnrn rn return checkInfo;rn rn rn我调用这个bean总是返回null,并且在控制台显示:rnOpenDB.executeQuery();[Microsoft][ODBC SOL Server Driver]rn[SOL Server]列名'系统管理员'无效。其中有两个字乱码!
求教:getResourceAsStream 为何总是返回null
代码如下:rn response.setHeader("content-disposition", "attachment;filename=A.jpg");rn InputStream in = this.getServletContext().getResourceAsStream("/img/A.jpg");rn byte buffer[] = new byte[1024];rn int len = 0;rn OutputStream out = response.getOutputStream();rn while ((len = in.read(buffer)) > 0) rn out.write(buffer, 0, len);rn rn in.close();rnrn文件与路径是没问题,否则第二行会报错,但就算不报错,返回总是null,搞不清楚,救教大家。
listview中setimagelist返回NULL
imagelist创建没问题,可是listview_setimagelist返回总是NULL,我查了一下setimagelist应该是成功了,而且图标也显示出来了。rn可是不管我把每个item的image设为多少,每个item显示的都是imagelist的第一个图标(即index为0的那项),怎么回事啊?!rn我用的win32
servlet中 HibernateSessionFactory.getSession返回null
环境:MyEclipse6.5 + tomcat6.0 + Hibernate + SQL Server 2000 sp4rnWeb工程rn由Hibernate自动生成数据类代码,在servlet类的doPost中调用 Session session = HibernateSessionFactory.getSession();返回nullrn但同样建一个Java Project,在main函数下执行相同代码就通过,不知为什么?rn查了论坛上的帖子,始终没有找到答案。有一个关于oracle的,也是在java工程中通过,在Web工程中getSession()返回null,回答说是“是驱动的问题,我用的是jdk1.6,把class12拷到lib下就可以了,另外使用ojdbc14_g.jar也可以.”rn但SQL Server下的没有。rn是哪里配置不对吗?rnrn
openssl问题求教
我用的版本时openssl-0.9.7-stable-SNAP-20020313,开发平台为vc6+win2000。rn程序起来后,有7,8个线程采用SSL通讯,这时有时会出现程序崩溃的现象,出错位置总是指向ssleay32.dll上。rn我已经调用CRYPTO_set_locking_callback设置了互斥量。不知为何还会出错,从现象看,很像临界资源访问出错。rn然而确不明就里,如蒙赐教,不胜感激!
求教安装OPENSSL的问题
在NT下预安装OPENSSL0.9.5。采用PERL5.OOO5-3.rn1、>perl CONFIGURE VC-WIN32执行后提示:<*.h>文件已转换为文件;rn2、>nmake -f ms\ntdll.mak后提示无法make ./crypto/cryptlib.h。rn打开cryptlib.h文件,其中的包含文件均为格式。rn为什么不能make?rn在install文件中提到兼容性问题:需要改动应用的MakeFile文件,使其指向../include/openssl。有许多的MakeFile文件,我分别改了crypto目录的MakeFile和总目录下的MakeFile,但都不管用。rn为什么?rn我是新手,但这是单位交给我的第一个有意义的工作,我很想做好。恳请高手帮忙。
求教 openssl编译出问题
link /nologo /subsystem:console /opt:ref /debug /dll /out:out32dll\liberny32.dll /def:ms/LIBEAY32.def @C:\Users\szd\AppData\Local\Temp\nm3258.tmprn 正在创建库 out32dll\libeay32.lib 和对象 out32dll\libeay32.exprncryptlib.obj : error LNK2019: 无法解析的外部符号 _OPENSSL_ia32_cpuid,该符号在函rn数 _OPENSSL_cpuid_setup 中被引用rnout32dll\libeay32.dll : fatal error LNK1120: 1 个无法解析的外部命令rnNMAKE : fatal error U1077: “"D:\visual studio\VC\BIN\link.EXE"”: 返回代码“0xrn60”rnStop.rn[b]编译了几次都是这样的问题,请大神支招!![/b]
c程序中的NULL
#includern#includern#define LIAN sizeof(struct lianbiao)rnstruct lianbiaorn rn int num;rn struct lianbiao *next;rn struct lianbiao *before;rn ;rnvoid inputlian(struct lianbiao*);//输入链表rnvoid outputlianfromhead(struct lianbiao*);//输出链表rnvoid outputlianfromend(struct lianbiao*);//输出链表rn//void insertnum();//插入数字rn//void deletenum();//删除数字rnint total=0;rnint main()rnrn struct lianbiao *head,*end;rn //l1=(struct lianbiao*)malloc(100*sizeof(struct lianbiao));rn end=((struct lianbiao*)malloc(LIAN));rn head=end;rn head->before=NULL;rn end->next=NULL;rn inputlian(end);rn outputlianfromhead(head);rn outputlianfromend(end);rn return 0;rnrn//----------------------------------------------------------------------------------------------------------------------rnvoid inputlian(struct lianbiao* l1)rnrn int a;rn struct lianbiao *l2;rn scanf("%d",&a);rn while(a!=0)rn rn ++total;rn l1->num=a;rn printf("---%d\n",l1->num);rn l2=((struct lianbiao*)malloc(LIAN));rn l1->next=l2;rn l2->before=l1;rn l1=l2;rn scanf("%d",&a);rn ;rn l1=NULL;rnrn//----------------------------------------------------------------------------------------------------------------------rnvoid outputlianfromend(struct lianbiao* e)rnrn struct lianbiao* p;rn p=e;rn p=p->before;rn while(p!=NULL)rn rn printf("%d\n",p->num);rn p=p->before;rn rnrn//----------------------------------------------------------------------------------------------------------------------rnvoid outputlianfromhead(struct lianbiao* h)rnrn struct lianbiao* p;rn p=h;rn while(p!=NULL)rn rn printf("%d\n",p->num);rn p=p->next;rn rn//该程序输出链表时while(p!=NULL)好像没有用一样,当链表输出完时,指针接着往下指,然后结果就显示该内存不可读了,用的是vc++6.0编译器。。
C中NULL的问题
TC中NULL用的时候要不要给它预先赋值,比如用#define NULL 0 之类的
WPF调用c dll 数组返回NULL
C++ DLL 中:rnDATAPRODLL_API int32 dataProcessOfflineTest1(double* a)rnrn *a = (*a) *2;rn return 1;rnrnDATAPRODLL_API double dataProcessOfflineTest2(double *in_2sPkt)rnrn if (in_2sPkt == NULL)rn return 0;rn return (*in_2sPkt)+*(in_2sPkt+1);rnrnrnDATAPRODLL_API int32 dataProcessOfflineTest3(double *in_2sPkt)rnrn if (in_2sPkt == NULL)rn return 0;rn *(in_2sPkt) = 3.5;rn *(in_2sPkt+1) = 100.258;rn *(in_2sPkt+2) = -1458.2;rn return 3;rnrnrnC#:rndouble[] testBuf = new double[5];rn Array.Clear(testBuf, 0, 5);rn testBuf[0] = 1.1;rn testBuf[1] = 2.1;rn flg1 = dataProcessOfflineTest1(ref testBuf[0]); //----(1)rn double tmp = dataProcessOfflineTest2(testBuf); //-----(2)rn flg1 = dataProcessOfflineTest3(out testBuf); //(3)rn其中:(1) (2) 都OK,可以实现在dll中对 testBuf[0] 2倍赋值,可以求和,,但经过(3)flg1 = 3,但testBuf变成了NULLrnrnps:dataProcessOfflineTest3 无论用 ref 还是 out都一样,rnrnWHY??求解rn
关于OpenSSL网络通讯的SSL_accept返回
小弟初学opnessl,遇见问题,先谢过了。rnssl_accept()返回值为-1,详细为 SSLv3 read client certificate brn 我是server端与client端都在一个pc上运行的,client端就没报错。求解。。
malloc返回null 急!!
#includern#includern#includernrntypedef struct studentrnrnstruct student *Next;rnchar Name[10];rnlong ID; //学号rnint Class;rnenum sexsM,WSex;rnstruct Daternrnint Year;rnint Month;rnint Day;rnBirthday;rnchar Phonenum[12];rnstruct scorernrnint Chinese;rnint Math;rnint English;rnfloat Average;rnScores;rnstud;rntypedef stud* studpt;rnrnstudpt Insert(studpt T)rnrnstudpt Tmp=NULL,Add=NULL;rnchar select;rnAdd=malloc(sizeof(stud)); //就这里出错!!一直返回null?什么原因啊?rnif(Add==NULL);rnrnprintf("Create memory space error!\n");rnreturn T;rnrnAdd->Next=NULL;rndornrnselect=InputImf(Add);rnwhile(select=='N'||select=='n');rnif(select=='e'||select=='E')rnrnfree(Add);rnprintf("Insert gave up!\n");rnreturn T;rnrnif(select!='y'||select!='Y')rnrnprintf("Wrong input! Exit!\n");rnfree(Add);rnreturn T;rnrnTmp=T;rnif(T->ID>Add->ID)rnrnTmp=Add;rnAdd->Next=T;rnrnelsernrnwhile(T->Next)rnrnif(T->Next->ID=Add->ID)rnrnAdd->Next=T->Next;rnT=Add;rnbreak;rnrnT=T->Next;rnrnif(Add->Next==NULL)rnT->Next=Add;rnrnprintf("Insert success!\n");rnreturn Tmp;rnrnrnvoid main ()rnrn int functionnum =0;rnstudpt T = NULL,p=NULL,head=NULL;rnT=Insert( T);rn head=T;p=T->Next;rnwhile(p)rnrnT=p->Next;rnfree(p);rnp=T->Next;rnrnif(head!=NULL)rnfree(head);rnrn
为什么Assembly.GetType()返回null?
我有一个程序片断rn string className = profilePath + ".PetShopProfileProvider";rn Assembly tmp = Assembly.Load(profilePath);rn System.Type type = tmp.GetType(className);rn跟踪调试tmp不为空,说明load程序集成功,可是后面的tmp.GetType(className)却总是返回null,明明className类是存在的啊,哪位高人指点一下啊?
为什么OpenMutex返回NULL?
我自己照书上写了个线程程序,创建3个线程,每个线程的代码基本一样,只是一些命名和显示的坐标参数不一样。ThreadProc也是共用的一个,其中每个线程都会OpenMutex一下各自mutex对象,判断一下返回值是否为空,结果就第一个线程的返回值不为空,剩下2个都返回空。但是换一台电脑执行,却没问题。是不是跟CPU个数有关啊?rnrn代码我就不贴了,话说这CSDN上打字真的很艰难,感觉卡得要死。远没有在贴吧发帖打字来得流畅啊。
AVIStreamGetFrameOpen总是返回NULL
我用二进制打开AVI文件以后发现AVI视频的图像是MJPG格式的,现在我想用API函数来播放这个AVI文件,写好的代码播放没压缩的AVI是可以的,但是播放这个视频图像是MJPG格式时就出了问题,跟踪以后发现是AVIStreamGetFrameOpen总是返回NULL下面是我的代码rn PAVIFILE pfile; //avi文件打开对象rn AVIFILEINFO pfi; //文件信息rn AVISTREAMINFO aviStrInfo;rn PAVISTREAM pavi; //流信息rn PGETFRAME pgf; //帧信息rn AVIFileInit();rn AVIFileOpen(&pfile,path,OF_READ | OF_SHARE_EXCLUSIVE,NULL);rn AVIFileInfo(pfile,&pfi,sizeof(AVIFILEINFO));rn AVIFileGetStream(pfile,&pavi,streamtypeVIDEO,0);rn[color=#FF0000] pgf = AVIStreamGetFrameOpen(pavi, NULL);//总是返回NULL[/color]rn if(NULL == pgf)rn rn AVIStreamRelease(pavi);rn return NULL;rn rn lp=(BYTE *)AVIStreamGetFrame(pgf,shownum);//提取第m_nowshow帧 由于前面返回NULL,接下来的代码就不运行rn if(NULL == lp)rn rn AVIStreamGetFrameClose(pgf);rn AVIStreamRelease(pavi);rn return NULL;rn rn请高手指点一下,不知道的也请帮顶一下,谢谢啦~~果有描述的不清楚的地方请尽管指出来,我尽力再说详细些~rn
CComboBoxEx SetImageList 返回NULL
CImageList *pImageList=new CImageList;rn pImageList->Create(16, 16, ILC_COLORDDB|ILC_MASK, 0, 1);rn HBITMAP hBitMap;rn CBitmap *pBitMap;rn hBitMap=LoadALLPIC("res\\image044.jpg");rn pBitMap=new CBitmap;rn pBitMap->Attach(hBitMap);rn pImageList->Add(pBitMap,RGB(0,0,0));rn //delete pBitMap;rn CImageList* a=m_ExBox.SetImageList(pImageList);rna==NULL,这是怎么回事,rnpImageList->Create(16, 16, ILC_COLORDDB|ILC_MASK, 0, 1);rn这个Create函数应该如何设置,是不是这个函数的问题导致的,rn我的图片是jpg的,多少色的我也不清楚,怎么知道是多少色的呢?rn
classload.getResource("/")没有返回null
当我的项目中添加了nalipay-sdk-java20150407220053.jarn这个jar包时,n使用类加载器的getResource("/")方法里,n竟然可以得到路径,当我去掉这个jar包时n就是返回的null,网上的资料都说这样时只会返回null的;n抱歉没有C币了n![图片说明](https://img-ask.csdn.net/upload/201508/13/1439477813_588768.png)
GetCapture总返回NULL
问题如[url=http://topic.csdn.net/u/20081015/22/0d70dace-e38e-4537-bc2f-a288702dc937.html?23340]http://topic.csdn.net/u/20081015/22/0d70dace-e38e-4537-bc2f-a288702dc937.html?23340[/url]rnrn但是后面的回答没有回答到点上,仍然不能解决问题。不知道为什么LZ觉得“已解决”。我的疑问是:rnrn我知道GetCapture是怎么工作的,但问题是,鼠标在窗口A,它的事件就应该被窗口A捕获,对不对?那么在窗口A中点击时,应该返回的是窗口A对不对?那为什么返回是NULL?rn我今天刚好遇到了这个问题,非常郁闷。先SetCapture一次,没有问题,在任何地方都能正常返回窗口A;但如果不SetCapture,在任何地方都返回NULL!至少在窗口A中应该返回窗口A对吧?
FindResource返回NULL
我在主程序添加一个窗体(例如Clogin LoginDlg ),然后想利用LoginDlg.DoModal()去显示这个窗。当利用主程序中的成员函数去调用LoginDlg.DoModal()。是可以显示LoginDlg窗体的。但我的主程序里有个回调函数。我想在该回调函数里利用LoginDlg.DoModal()去显示LoginDlg窗体,却显示不出来。我跟踪到DoModal()函数中去发现,DoModal()里面的HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);返回的是NULL。所以显示不出来。这将如何解决,谢谢!
select @@identity返回null
用的微软企业库rn三层架构 最后调用DAL里的SaveUser方法 返回不了@@identity rnrn[color=#FF0000]可是我把完全相同的代码重新复制到一个新的项目(同一解决方案里),为了方便测试用的winform项目。然后再执行就返回出结果了 为什么在网站项目里他就null呢[/color]rnrn[code=C#]rnrn public int SaveUsers(Users users)rn rn using (IDbConnection conn = db.CreateConnection())rn rn conn.Open();rn IDbTransaction trans = conn.BeginTransaction();rn string sql = string.Format("insert into [Users](username,Password,Tel,Address,level,alipay,reg_leave) values ('0','1','2','3','4','5','6');select @@identity", users.UserName, users.PassWord, users.Tel, users.Address, "1", users.Alipay, users.RegLeave);rn return Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));rn rn rn[/code]
fopen返回NULL
以下是代码rn求解为什么会fopen返回NULL;rn#include rn#include rn#include rn#include rn#include rnrn#define TURE 1rnrn#define LOCAL_SERVER_PORT 5866rn#define MAX_MSG 1024rnrnint main(void)rnrn int n, fd;rn socklen_t cli_addr_len;rn char buf[MAX_MSG] = 0;rn unsigned long int npak=0;rn struct sockaddr_in servaddr, cliaddr;rn FILE *fp;rn int KZ=0;rn int sendbufsize,recvbufsize;rn int size=4;rnrn printf("n%20 printf or 1 printf or no printf(2/1/0)?");//多少个包打印一次rn scanf("%d", &KZ);rn printf("stat:\n");rn if((fp=fopen("udp.dat", "wb")) == NULL)rn rn printf("error - open file.");rn return 0;rn rn if((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)rn rn printf("socket error!\n");rn exit(0);rn rnrn servaddr.sin_family = AF_INET;rn servaddr.sin_addr.s_addr = htonl(INADDR_ANY);rn servaddr.sin_port = htons(LOCAL_SERVER_PORT);rn bind(fd, (struct sockaddr *)&servaddr, sizeof(servaddr));rnrn //设置系统缓冲区大小rn size = sizeof(int);rn recvbufsize = 0;rn if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&recvbufsize, &size) == 0)rn printf("recvbufsize = %d\n", recvbufsize);rn recvbufsize = 128*1024;rn if(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&recvbufsize, sizeof(int)) == 0 )rn printf("recvbufsize = %d\n", recvbufsize);rn if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *)&recvbufsize, &size) == 0)rn printf("recvbufsize = %d\n", recvbufsize);rnrnrn while(TURE)rn rn cli_addr_len = sizeof(cliaddr);rn n =recvfrom(fd, buf,MAX_MSG, 0, (struct sockaddr *)&cliaddr, &cli_addr_len);//接收数据rn npak++;rn if((KZ==2) && !(npak%20))rn printf("%d\n", npak);rn else if(KZ == 1)rn printf("%d\n", npak);rn fwrite(buf, MAX_MSG, 1, fp);//写硬盘,每一个包一写rn rn fclose(fp);rn return 0;rn
AjaxPro执行返回null
.csrn[code=C#]rnpublic static int flag = 0;rn protected void Page_Load(object sender, EventArgs e)rn rn AjaxPro.Utility.RegisterTypeForAjax(typeof(admin_admin_News));rn if (!IsPostBack)rn rn BindNewsClassData();rn SetBind("");rn rn rn [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]rn public int News_Orders()rn rn if(flag == 0)rn rn flag = 1;rn SetBind("P_Name desc,");rn rn elsern rn flag = 0;rn SetBind("P_Name asc,");rn rn return flag;rn rn[/code]rnrn.aspxrn[code=HTML]function sufun()rnrn alert(admin_admin_News.News_Orders().value);rn alert("222");rn [/code]rn执行后弹出null然后又弹出222rn怎么办?
使用gethostbyname返回NULL
我使用gethostbyname来获得IP地址,但是总是返回NULL,请问怎么回事?rn补充,我已经设置了DNS,并且能够成功ping 域名
读取通讯录返回NULL
Cursor cursor=c.getContentResolver().query(Contacts.People.CONTENT_URI,null,null,null,null);rn while(cursor.moveToNext())rn nameFieldColumnIndex = cursor.getColumnIndexOrThrow(Contacts.People.NAME);rn name = cursor.getString(nameFieldColumnIndex);rn numberFieldColumnIndex = cursor.getColumnIndexOrThrow(Contacts.People.NUMBER);rn number1 = cursor.getString(numberFieldColumnIndex); rn //System.out.println(name); rn // System.out.println(number1);rn if(number1==null)rn Toast.makeText(c, name+"请求跟踪", Toast.LENGTH_LONG).show(); rn System.out.println("reach");rn rn rn rn 通讯录里放了两个人:shen 5556;dergin 1234 以上代码运行number1为null 名字打印出来为shen,dergin,[b]为什么没号码?
this.locationManager.getLastKnownLocation(provider);返回null
[code=java]rnthis.locationManager=(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);rn List pStrings=this.locationManager.getProviders(true);rn if (pStrings.contains(LocationManager.GPS_PROVIDER)) rn provider=LocationManager.GPS_PROVIDER;rn rn else if (pStrings.contains(LocationManager.NETWORK_PROVIDER)) rn provider=LocationManager.NETWORK_PROVIDER;rn rn else rn Toast.makeText(this, "no gps", Toast.LENGTH_SHORT).show();rn return;rn rn location=this.locationManager.getLastKnownLocation(provider);rn[/code]rn手机只设置了gps定位,用gps的provider,总是返回null,权限设置了如下三个:rn rn rn rn但是同样只设置GPS定位,用陌陌,大众点评什么的都可以定位到附近,这是为什么?代码哪里有问题?rn同样代码,改成用network获取就可以得到location
ImageIo.read() 返回null
具体代码如下:nimgStr是一个base64字符串npublic static String decoderQRCodeForBase64(String imgStr) throws Exception n if (imgStr == null) n return "";n nn BASE64Decoder decoder = new BASE64Decoder();n byte[] b = decoder.decodeBuffer(imgStr);n for (int i = 0; i < b.length; ++i) n if (b[i] < 0) // 调整异常数据n b[i] += 256;n n nn InputStream input = new ByteArrayInputStream(b);nn String content = decoderQRCode(input);nn return content;nn n n n public static String decoderQRCode(InputStream input) throws Exception n BufferedImage bufImg = null;n String content = null;nn bufImg = ImageIO.read(input);n QRCodeDecoder decoder = new QRCodeDecoder();n content = new String(decoder.decode(new TwoDimensionCodeImage(bufImg)),n "utf-8");nn return content;n n n 在bufImg = ImageIO.read(input);这里读不出来,返回的是null,为什么呢,求大神解答,小白在线等。
getActivity()返回null的解决问题
如果从最近使用的应用里面点击我们的应用,系统会恢复之前被回收的Activity,这个时候FragmentActivity在oncreate里面也会做Fragment的恢复,但是此时恢复出的Fragment,在调用getActivity的时候会返回null。 解决方法: 如果该Context需要在Activity被销毁后还存在, 则使用getActivity().getApplicatio
LoadImage总是返回NULL
HBITMAP hBit = (HBITMAP)::LoadImage((HINSTANCE)GetModuleHandle(NULL), _T("C:\\CLOSED.BMP"), IMAGE_BITMAP, NULL, NULL, 0);rnrn返回NULL,GetLastError()返回1814(找不到映像文件中指定的资源名)rnrnHBITMAP hBit = SHLoadDIBitmap(_T("C:\\CLOSED.BMP"));rn返回NULL。GetLastError()返回3(找不到路径)rn可是确实存在这个文件啊
datatable.getchanges()为啥返回null
具体情况:界面中设计一个datagridview,手动添加列,将列1和列2绑定某个字段,列1和列2的类型为复选框类型。设置选中为Y,不选中为N。然后在代码中给该datagridview绑定一个datatable。绑定修改列1和列2的值。通过断点可以看到datatable的值已经改变。但是datatable.getchanges()返回却是null。这是怎么个情况?
document.getElementById 返回null,为什么?
[size=18px]定义一个标签:rnrn用JS:var g_input = document.getElementById(guess_input);rn为什么g_input=null???rn求助高手[/size]
struts2 ajax返回null
刚接触ajax和json,遇到点小问题,半天都没解决,希望大侠们支援哪。。。rn感激万分~~rnajax调用action顺利执行了,result里有了内容,但页面弹框显示为null或者直接不显示rn[code=Java]rnimport org.json.JSONObject;rn//result、username的setter、getter方法rnpublic String showUser()rn List list = userDAO.findByUsername("king");rn System.out.println("userame"+userame);rn rn JSONObject obj=new JSONObject();rn try rn obj.put("users", list);rn result=obj.toString();rn System.out.println("result: "+result);rn //显示:result: "users":["userpassword":"king","username":"king","userid":1]rn catch (JSONException e) rn e.printStackTrace();rn rn return Action.NONE;rn //return SUCCESS;//换成这句js不能弹窗 rn rn[/code]rnAction成功调用,username接收正常,rnstruts2.1.6:rn[code=XML]rnrn rn rn rn rn rn rn[/code]rnrnjsp页面js:rn[code=JScript]rn rn[/code]
GetDlgItem返回NULL
int WINAPI WinMain( HINSTANCE hInstance,rn HINSTANCE hPrevInstance,rn LPWSTR lpCmdLine,rn int nCmdShow)rnrn InitCommonControls();rn ImmDisableIME(0);rn DialogBox(hInstance,MAKEINTRESOURCE(IDD_WIFIDIALOG),NULL,(DLGPROC)WifiDlgProc);rn return 1;rnrnrnLRESULT CALLBACK WifiDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)rnrn int myid;rn DWORD dwStyle;rn CListCtrl *m_WifiList;rn/* if (myedit == NULL)rn rn MessageBox(hDlg,TEXT("list error"),NULL,MB_OK);rn */rn switch(message)rn rn case WM_INITDIALOG:rn rn m_WifiList = (CListCtrl*)GetDlgItem(hDlg,IDC_LIST1);rn (CListCtrl*)GetDlgItem(hDlg,IDC_LIST1)->EnableWindow(TRUE);rn int sx, sy;rn sx = GetSystemMetrics(SM_CXSCREEN);rn sy = GetSystemMetrics(SM_CYSCREEN);rn SetWindowPos(hDlg, 0, 0, 0, sx, sy-23, SWP_NOZORDER);rn rn dwStyle = m_WifiList)->GetExtendedStyle();rn dwStyle |= LVS_EX_CHECKBOXES;rn dwStyle |= LVS_EX_ONECLICKACTIVATE;rn dwStyle |= LVS_EX_SUBITEMIMAGES;rn m_WifiList->SetExtendedStyle(dwStyle);rn return TRUE;rn rn case WM_COMMAND:rn rn myid = LOWORD(wParam);rn switch(myid)rn rn case IDOK:rn EndDialog(hDlg,IDOK);rn return FALSE;rn case IDCANCEL:rn EndDialog(hDlg,IDCANCEL);rn return FALSE;rn rn rn default:rn return FALSE;rn rn
Attribute.GetCustomAttribute() 返回为null
[code=csharp]rnnamespace LookUpWhatsNewrnrn internal class WhatsNewCheckerrn rn private static readonly StringBuilder outPutText = new StringBuilder();rn private static DateTime backDateTo = new DateTime(2010,2,1);rnrn static void Main(string[] args)rn rn Assembly theAssembly = Assembly.Load("VectorClass");rn Attribute supportsAttibute = Attribute.GetCustomAttribute(theAssembly, typeof(LastModifiedAttribute));// supportsAttibute 为空! rn Conso.Read();rn rn rnrnrnnamespace WhatNewAttributesrnrn [AttributeUsage(AttributeTargets .Class |AttributeTargets.Method ,AllowMultiple =true ,Inherited =false )]rn public class LastModifiedAttribute:Attribute rn rn private readonly DateTime dateModified;rn private readonly string changes;rn public LastModifiedAttribute(string dateModified, string changes)rn rn this.dateModified = DateTime.Parse(dateModified);rn this.changes = changes;rn rn public DateTime DateModifiedrn rn getrn rn return this.dateModified;rn rn rn public string Changesrn rn getrn rn return this.changes;rn rn rn public string Issues get; set; rn rn [AttributeUsage(AttributeTargets.Assembly)]rn public class SupportWhatsNewAttribute : Attributern rn rnrnrnnamespace VectorClassrnrn [LastModifiedAttribute("14,Feb,2010", "IEnumerable interface implemented so vector can now be treated as a Collection")]rn [LastModifiedAttribute("10,Feb,2010", "IFormattable interface implemented so vector now responds to format specifiers N and VE")]rn public class Vector:IEnumerable ,IFormattablern rn public double x, y, z;rn public Vector(double x,double y,double z)rn rn this.x = x;rn this.y = y;rn this.z = z;rn rnrn [LastModifiedAttribute("10,Feb,2010", "Method added in order to formating support")]rn public string ToString(string format, IFormatProvider formatProvider)rn rn if (format == null)rn rn return ToString();rn rnrn switch (format)rn rn case "N":rn return string.Format("(0,1,2)", x, y, z);rn case "VE":rn return string.Format("0i+1j+2k", x, y, z);rn default:rn throw new ArgumentException("No 0 format !", format);rn rn rnrn public string ToString(string format)rn rn return ToString(format, null);rn rnrn public IEnumerator GetEnumerator()rn rn yield return x;rn yield return y;rn yield return z;rn rn [LastModifiedAttribute("14,Feb,2010", "Class create as part of collection support for Vector")]rn private class VectorIEnumerator : IEnumeratorrn rnrn public object Currentrn rn get throw new NotImplementedException(); rn rnrn public bool MoveNext()rn rn throw new NotImplementedException();rn rnrn public void Reset()rn rn throw new NotImplementedException();rn rn rn rn[/code]
为什么spriteFrameByName返回NULL
在使用spriteFrameByName得到的sprite frame来构animation的时候,得到一个NULL指针rnrn在使用前已经在一个layer init里去加载了.plist文件(bullet.plist是已经打包好的一些.png文件的配置文件)rnrnCCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("bullet.plist")rn但是在CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bullet_1.png")的时候出问题了,得到一个NULL指针.rnrn查看了bullet.plist文件,里面有bullet_1.png等文件信息, 麻烦哪位能帮忙解答一下这种情况是什么原因?rnrnbullet_1.pngrn rn framern 2,135,65,131rn offsetrn 0,1rn rotatedrn rn sourceColorRectrn 0,0,65,131rn sourceSizern 65,133rn
preg_replace 返回 null
代买如下:rn$p='/(?
GetProp()总返回NULL
代码如下,CMmywnd是我封装的窗口类,MY_WND_PROP_NAME在头文件里定义为_T("name")rnrnLRESULT CALLBACK CMywnd::WndProc(HWND hWnd, UINT nMsg,WPARAM wp,LPARAM lp)rnrnLRESULT lResult=0;rnBOOL bCallDefault=TRUE;rnCMywnd *pWnd=(CMywnd*)GetProp(hWnd,MY_WND_PROP_NAME);rnif(pWnd==NULL)rnrnif(nMsg!=WM_CREATE)rnrnreturn DefWindowProc(hWnd,nMsg,wp,lp);rnrnelsernrnLPCREATESTRUCT pSt=(LPCREATESTRUCT)lp;rnpWnd=(CMywnd*)pSt->lpCreateParams;rnSetProp(hWnd,MY_WND_PROP_NAME,pWnd);//这个操作似乎没用,pWnd总是NULLrnrnrnif(!pWnd->PreProcessMsg(hWnd,nMsg,wp,lp,&lResult))rnreturn lResult;rnint wmId;rnswitch(nMsg)rnrncase WM_COMMAND:rnwmId = LOWORD(wp);rnswitch(wmId)rnrncase ID_CONSOLE_SHUTUP:rnrnbreak;rnrnbreak;rncase WM_CREATE:rnrnpWnd->m_hWnd=hWnd;rnlResult=pWnd->OnCreat(hWnd);rnbCallDefault=FALSE;rnbreak;rnrncase WM_DESTROY:rnbCallDefault=pWnd->OnCommand(LOWORD(wp));rnbreak;rncase WM_CLOSE:rnpWnd->Destroy();rnbCallDefault=FALSE;rnbreak;rndefault:rnbreak;rnrnif(bCallDefault)rnreturn DefWindowProc(hWnd,nMsg,wp,lp);rnelsernreturn lResult;rn
相关热词 c#部署端口监听项目、 c#接口中的属性使用方法 c# 昨天 c#func链接匿名方法 c#怎么创建文件夹 c#从键盘接收空格 c#da/ad c#部门请假管理系统 c#服务器socket c# 默认的访问修饰符