Opened 12 years ago

Closed 10 years ago

#1879 closed defect (wontfix)

Maestro API - Fail to Create RuntimeMap

Reported by: crispinatime Owned by: jng
Priority: medium Milestone: Maestro-5.1
Component: Maestro Version:
Severity: major Keywords: Maestro API
Cc: External ID:

Description

A change in the Maestro API sometime in the last few weeks now results in an exception being thrown when creating a runtime map.

I rolled back some Maestro API DLLs that I had built and my app runs again - hopefully there is enough in the stack trace to see what the issue is.

It looks to be layer-dependent as on my test data in the office it does not occur, only on a complex site with many data connection types (SHP, SDF, ODBC) including joins and base layers.

The build that caused the err below was from Friday 3 December.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 248: Line 249: RuntimeMap rtMap = mpSvc.CreateMap(md); Line 250:

Source File: e:\Projects\-blah-\mapFrame.aspx.cs Line: 249

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

OSGeo.MapGuide.MaestroAPI.Mapping.RuntimeMapLayer.InitIdentityProperties(IVectorLayerDefinition vl) +110 OSGeo.MapGuide.MaestroAPI.Mapping.RuntimeMapLayer..ctor(RuntimeMap parent, ILayerDefinition ldf) +169 OSGeo.MapGuide.MaestroAPI.Mapping.RuntimeMapLayer..ctor(RuntimeMap parent, IBaseMapLayer source, ILayerDefinition ldf) +60 OSGeo.MapGuide.MaestroAPI.Mapping.RuntimeMap..ctor(IMapDefinition mdf, Double metersPerUnit) +570 OSGeo.MapGuide.MaestroAPI.PlatformConnectionBase.CreateMap(String runtimeMapResourceId, IMapDefinition mdf, Double metersPerUnit) +38 OSGeo.MapGuide.MaestroAPI.PlatformConnectionBase.CreateMap(String runtimeMapResourceId, IMapDefinition mdf) +63 OSGeo.MapGuide.MaestroAPI.PlatformConnectionBase.CreateMap(IMapDefinition mdf) +95 OSGeo.MapGuide.MaestroAPI.HttpServerConnection.OSGeo.MapGuide.MaestroAPI.Services.IMappingService.CreateMap(IMapDefinition ) +5 _Default.Page_Load(Object sender, EventArgs e) in e:\Projects\-blah-\mapFrame.aspx.cs:249 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Change History (9)

comment:1 by jng, 12 years ago

I presume you are building from source. Can you get line numbers for this? Just drop the pdbs in the same bin dir.

comment:2 by jng, 12 years ago

I do know of a problem trying to get the class definition of an extended (joined) feature class over HTTP. This may be causing some trip ups?

comment:3 by crispinatime, 12 years ago

I am offsite now so won't get any PDBs there for a few days.

Looking through the SVN changelog there is an obvious culprit in 6221 including

" - Fetch and assign identity properties for newly created RuntimeMapLayer objects "

This adds the InitIdentityProperties(vld) at line 192 of that version of RuntimeMapLayer.cs which is the err thrown in the stack trace.

There is an "idProps.Count" and a "foreach" over the idProps - but if idProps is null? that would throw the exception?

comment:4 by crispinatime, 12 years ago

Hi,

I put a try/catch in my code and it worked - though I also added the following to the catch{} block.

With the Trace.TraceWarning() - I assume there is no feature to actually log an exception when using the API at runtime, such as to a file - because I can't get this to fail on my dev environment at all!

C

var propInfo = new PropertyInfo[0]; this.IdentityProperties = propInfo;

comment:5 by jng, 12 years ago

I'd really want to try to dig into the cause of why a Null Reference is happening. I haven't been able to reproduce this problem thus far. The TraceWarning() I put in means such exceptions if caught, will be logged to your VS window when debugging under VS, or you can configure ASP.net to display all trace output (http://msdn.microsoft.com/en-us/library/b0ectfxd.aspx)

Setting identity properties to an empty array will just make the layer unselectable (regardless of the Selectable flag on it).

comment:6 by crispinatime, 12 years ago

OK - I didn't know if it was safer to leave this.IdentityProperties as null or not.

The redirect of trace to ASP.NET link is helpful - this case probably won't be updated for a week or two until I am onsite again and can run this on test

comment:7 by jng, 12 years ago

Milestone: Maestro-4.0Maestro-4.1

this.IdentityProperties couldn't be null reference because it is initialized to an empty array in the ctor that all other ctors chain into.

The try/catch is a suitable workaround for now. If you have unselectable layers (and the Selectable flag is on for that layer), then more information about those layers can shed some light into this problem.

Deferring to later milestone

comment:8 by crispinatime, 12 years ago

This issue hit a break on the Trace today and when I looked in the MG Server logs at the same instant I saw that one of my layers is failing because the .FeatureSource (Oracle in this case) is invalid.

Please see below MapGuide trace and MGServer log.

Obviously it's ideal to have all ones connections working, but Maestro should throw a meaningful error, rather than a NullRefEx

System.NullReferenceException: Object reference not set to an instance of an object.

at OSGeo.MapGuide.MaestroAPI.Mapping.RuntimeMapLayer.InitIdentityProperties(IVectorLayerDefinition vl) in E:\Projects\Maestro\OSGeo.MapGuide.MaestroAPI\Mapping\RuntimeMapLayer.cs:line 281

<2012-01-21T16:54:03> 4852 MapGuide Maestro API v4.0.0.6359 ::1 Administrator

Error: An exception occurred in FDO component.

ORA-12170: TNS:Connect timeout occurred

comment:9 by jng, 10 years ago

Resolution: wontfix
Status: newclosed

r7957 lets you determine whether to create a RuntimeMap where such layer initialization failures are either swallowed up (current behaviour) or fails hard by letting the exception bubble up. The side-effect of swallowing up such errors is that that layer may not be selectable.

We can't really solve the underlying problem as an FDO provider could throw any kind of error that would prevent layer initialization

Note: See TracTickets for help on using tickets.