ADF开发中的【未将对象引用设置到对象的实例】解决之道

          最近在做ArcIMS  ADF开发,刚开始一切顺利,可进行到一半经常出现一个错误,错误提示如下:【An unhandled exception has occurred: 未将对象引用设置到对象的实例】。刚开始以为是自己的环境问题呢!所以我向朋友要了一份在他自己的系统里生成的模板网站,他那边运行没问题,可是在我这边运行却存在问题。

     因为自己安装的ArcIMS可以说是一个“合作搭档”,ArcIMS是在一个网站上下载的,而他的ADF插件又是在另外一个网站上下载的,我以为是这个的问题,而后面自己也打了sp6的补丁,所以在怀疑自己的环境。但是,昨晚上彻底的将原来安装的ArcIMS全部卸载后安装了新的一套,我以为问题不会出现了,结果安装完以后问题继续存在。我一边网上搜,一边在考虑自己的问题出在那里。我发现我现在生成的 模板网站有以下几个问题:

    第一个:点击toolbar的toolbaritems时会出错,我马上发现这是II的问题,我修改后这个问题就没了。如下图示:

 

    第二个:就是题目所要解决的问题还是存在,网上有以下解决办法:

            第一个解决方案:就是  Add ArcGis Indetity,如下图示,我添加了但是问题继续存在。

            第二个解决方案:就是从新 web applcation post install 一下就可以了,但是我的ARcIMs ADF现在用不到。

            第三个解决方案:就是在代码中添加如下代码:

                 if (!MapResourceManager1.Initialized)  MapResourceManager1.Initialize(); 但是我用此代码没有解决问题。

通过以上几个解决方案的实施,我的问题继续存在。

         我累呀!项目又逼的紧,没办法只好自己找问题,又从问题的开头思考问题,问题到底在那里,这个问题到底属于什么性质?

一边想思考问题的同时一边在网上找相关的资料,但问题始终得不到解决,不过发现解决此问题的一下解决方案,是英文的,我就不翻译了,大家看下:

   第一:

 Try this:
Open the code in Visual Studio. Right-click on the solution directory and choose "Add ArcGIS Identity". Enter a username & password that is valid for the secured machine, preferably an identity in the "agsadmin" group. Re-build the solution.

This worked for a similar problem that I had, hopefully it helps you out.

Good luck!

   第二:

I tried your tip and it worked for me. Usually this line has been good enough to access ArcGIS server resources:

< identity impersonate="true" />

Maybe it does not work anymore with sp3 installed.
I'm pretty sure that anonymous access is enabled for Authentication Methods on all my virtual folders.

Is their something I need for Windows Workgroup to enable anonymous access to the AGS Server?

I started a new topic on this issue before I found this work-around. Here is the link:
http://forums.esri.com/Thread.asp?c=158&f=2276&t=232581&mc=0

I was able to get a slightly better error message by logging the exception object in the map resource manager asp control. 
 第三:

I do not understand this problem. I had the same problem. I tried adding an identity, restarting service, resetting the properties of the map control and resource manager and even deleting and adding the map control from the application. This was plain vanilla application created out of the ESRI template. However, I deleted this application and recreated it and it worked! with the same set of server and service I was using before.
I don't even know how to recreate this problem now to be able to analyze anything further. 

第四:

Hi, i fixed an error like this (published a map website from VS 2005 to IIS 6) by adding the ArcGIS Identity in the project and adding write permissions for that identity to the .net framework temp folder C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files
Hope this helps some of you! 

 

最后阐述一下此问题的出现会让人无语:

I have an open support ticket with ESRI about this but thought I would try here to see if someone has had the same issue we have.

We can launch a web application but instead of displaying the data it gives us the error "An unhandled exception has occurred: Object reference not set to an instance of an object." It stacks these errors up about 10 times. The browser displays all the features of the default web application, just no data. We can preview both the service and the application and see the data just fine in the server manager. The problem does not occur until we try and launch the web application. The strange part is we have previously launched an application that is now on the web and works perfectly. The working application is published from a different mxd. In trying to launch a new one from a new mxd, we have encountered this issue. Our mxd is set up just as the one that has worked for us previously. The only thing that we have changed since successfully launching an application is added security measures on the box to protect our data.

Any help and suggestions is very much appreciated.

Thanks! 

 

 

我的问题还没解决,现在ArcIMS 的服务不能运行,是这个ServletExec 5.0 ISAPI的错误,我测试他时,他给我弹出一个文件要让我保存,不知什么原因,可能是我的电脑中毒了,最近经常出现一些乱七八糟的错误,上次我同事用我U盘,回来发现我的文件夹全部被隐藏,而且给没个文件夹创建了一个exe文件,哎...继续解决中。

 

当我用解决方案三解决问题的时候又发现新的错误,错误如下:

     Application Error

         Page_Error
         There was an error reading the SERVICE_INFO response. Please make sure that it contains valid ArcXML. Error Message: [ERR0137] Service - SanFrancisco has timed out..

 

  在 ds.b(String A_0) 在 ds.a(MapService& A_0) 在 ESRI.ArcGIS.ADF.IMS.Carto.MapService.Initialize() 在 ESRI.ArcGIS.ADF.IMS.Carto.MapService..ctor(IMSServerConnection connection, InitializationParameters initializationParameters, Boolean initializeOnConstruction) 在 ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapResource.LoadState() 在 ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem.CreateResource() 在 ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceManager`2.a() 在 ESRI.ArcGIS.ADF.Web.UI.WebControls.GISResourceManager`2.OnInit(EventArgs e) 在 System.Web.UI.Control.InitRecursive(Control namingContainer) 在 System.Web.UI.Control.InitRecursive(Control namingContainer) 在 System.Web.UI.Control.InitRecursive(Control namingContainer) 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


我知道上面这个问题解决了,现在的问题只是我的ArcIMS的服务没有启动而已!

ok !解决ArcIMs问题。

你可能感兴趣的:(ArcServer)