No symbols in referenced styles after loading a QueryDef FeatureClass

8066
12
10-07-2011 06:41 AM
karinweixler
New Contributor II
Hello,
after loading a QueryDef FeatureClass per Code (with IFeatureWorkspace.CreateQueryDef and .OpenFeatureQuery) and open the Layer Properties and the Tab Symbology, there are no Symbols loaded in the Symbol Selector if i wont to change the Style of my used Symbol, even there are some Style References by default (ESRI). The solution at the moment is to open the Style References check any of the Style Refernce and click ok. After that there are the default Style References loaded. Does someone has the same expirience with loaded QueryDef FeatureClasses? Back in ArcGIS 9.3 everything worked fine. Now with ArcGIS 10 SP 1 i have this strange behavior. Is there a differnt way now with ArcGIS 10 to load just a part of a FeatureClass then using CreateQueryDef?
Thanks in advance.
Karin
0 Kudos
12 Replies
karinweixler
New Contributor II
Ok, here are some more hints:
It seems not to be the thing that i load a QueryDef, the Problem also appears when i load a normal FeatureClass (IFeatureWorkspace.OpenFeatureClass) per Code.
Another thing: when i open arcmap by code (pDoc = new ESRI.ArcGIS.ArcMapUI.MxDocument; pApp = pDoc.Parent; pApp.Visible = True) and then point to the CommandItem and run the OnClick Event (where the FeatureClass are loaded) everything acts normal.
0 Kudos
karinweixler
New Contributor II
The Problem seems to be, when i connect to my Personal Geodatabase.
Code for that:

Private Function openAccessWorkspace(ByVal connString As String) As IFeatureWorkspace
            'Access workspace öffnen
            Dim pWS As IWorkspace2
            Dim pWorkspaceFactory As IWorkspaceFactory2
            openAccessWorkspace = Nothing
            Try
                pWorkspaceFactory = New AccessWorkspaceFactory
                pWS = pWorkspaceFactory.OpenFromFile(connString, 0)
                openAccessWorkspace = pWS
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Information, "openAccessWorkspace")
            End Try
End Function

After the connection i do load any FeatureClass per code from the workspace and there are again no symbols in the style references.
I really dont have a clue where's my mistake!
I already did an update for my PGDB to ArcGIS 10, but no change.
0 Kudos
karinweixler
New Contributor II
So, now i localized the problem:
For my pGDB-Connection i use a public shared variable and this seems to be a problem for ArcGIS and the Style References. If i set the connection to nothing after loading the FeatureClasses, the symbols are loaded in the style references. So the question is, why isnt it a problem if i load a mxd, because there i also use the public shared variable for the connection, but the symbols are shown in the style references. And how can i solve this thing? Any help would be great!
0 Kudos
NeilClemmons
Regular Contributor III
You mention opening ArcMap through code.  Is this a standalone application?  If so then you need to use IObjectFactory to create any instances of ArcObjects classes that you will be using with the running instance of ArcMap.
0 Kudos
karinweixler
New Contributor II
Thanks Neil for your reply. Well the thing is, that i dont have a problem if i open ArcMap through code (see comment 2). The Symbols are only not shown, when i open ArcMap and then connect to my PersonalGeodatabase with my public shared connection variable.
0 Kudos
RichWawrzonek
Occasional Contributor
I'm not sure if this is related to your problem Karin, but I ran into an issue using IQueryDef with ArcMap 10 also.  If I load a feature layer into ArcMap from code using IFeatureWorkspace.CreateQueryDef method from a file geodatabase source it will not display symbols if the map is using a projected coordinate system.  It displays normally in any geographic cs. The same code worked fine in 9.x,  I don't have a work around yet. Does your issue exist with geographic cs also?
0 Kudos
karinweixler
New Contributor II
Hello Rich, i tried both, projected and geografic, but there is no difference, same behaviour.
0 Kudos
NeilClemmons
Regular Contributor III
Thanks Neil for your reply. Well the thing is, that i dont have a problem if i open ArcMap through code (see comment 2). The Symbols are only not shown, when i open ArcMap and then connect to my PersonalGeodatabase with my public shared connection variable.


It's still unclear to me exactly what you're doing.  In your second command it seems like you're saying that you're opening ArcMap through code, getting a reference to a command inside of ArcMap and executing it.  That should work correctly because all of the code inside the command is running inside of ArcMap.  In your other posts I'm getting the idea that you're opening ArcMap through code and trying to automate it.  If this is the case then you cannot use the New keyword to instantiate any ArcObjects class that you intend to use in conjunction with ArcMap.  You must use IObjectFactory to create instances of these objects.
0 Kudos
karinweixler
New Contributor II
The Problems with the referenced styles appear when i open ArcMap (via arcmap.exe) and then connect to my Personal Geodatabase (in which i use a public shared variable for the connection) via code and load FeatureClasses into ArcMap. The Problem disappear when i open the StyleReferences Manager (from the property From of a Layer or form the Style Manager (Menu)) and do nothing then click ok to close it again. Hope i made my problem clear. Thanks for your help.
0 Kudos