[ArcEngine] rasterlayer转rasterdataset出现异常

这是我的在网上找的代码:

IRasterLayer rasterLayer = axMapControl1.get_Layer(iptIndex) as IRasterLayer;
                        IRaster raster = rasterLayer.Raster;
                        IRasterBandCollection rbcollection = raster as IRasterBandCollection;
                        IRasterBand rBand = rbcollection.Item(0);  //异常
                        IRasterDataset2 rasterDataset = rBand.RasterDataset as IRasterDataset2;  //rasterDataset为空

在调试过程中,发现第五行的rasterDataset为null,网上检查发现第四行的rBand在赋值时出现了COM异常,如图:
图片说明

请问各位大佬该怎么解决ing?。。。

https://blog.csdn.net/Prince999999/article/details/88027021