POST
|
Hi Guys. I am creating an extension for ArcMap 10.2 using Visual Studio 2012 C# WPF. Consider this code snippet:
//Open the CSV file
IWorkspaceFactory WorkspaceFactory = new TextFileWorkspaceFactoryClass();
IFeatureWorkspace FeatureWorkspace = (IFeatureWorkspace)WorkspaceFactory.OpenFromFile(FilePath, 0);
ITable Table = FeatureWorkspace.OpenTable(FileName);
IStandaloneTable StandaloneTable = new StandaloneTableClass();
StandaloneTable.Table = Table;
IMap Map = MxDocument.FocusMap;
IStandaloneTableCollection StandaloneTableCollection = (IStandaloneTableCollection)Map;
StandaloneTableCollection.AddStandaloneTable(StandaloneTable);
//Create the Event Layer of the data source
IDataset Dataset = (IDataset)StandaloneTable;
IName TableName = Dataset.FullName;
IXYEvent2FieldsProperties XYEvent2FieldsProperties = new XYEvent2FieldsPropertiesClass();
XYEvent2FieldsProperties.XFieldName = ColumnX;
XYEvent2FieldsProperties.YFieldName = ColumnY;
XYEvent2FieldsProperties.ZFieldName = String.Empty;
IXYEventSourceName XYEventSourceName = new XYEventSourceNameClass();
XYEventSourceName.EventProperties = XYEvent2FieldsProperties;
XYEventSourceName.EventTableName = TableName;
XYEventSourceName.SpatialReference = SpatialReference;
IName XYEventName = (IName)XYEventSourceName;
IXYEventSource XYEventSource = (IXYEventSource)XYEventName.Open();
//Map the Event Layer
IFeatureLayer FeatureLayer = new FeatureLayerClass();
FeatureLayer.FeatureClass = (IFeatureClass)XYEventSource;
FeatureLayer.Name = FileName;
//Add the layer extension (this is done so that when you edit the layer's Source properties and click the Set Data Source button, the Add XY Events Dialog appears)
ILayerExtensions LayerExtensions = (ILayerExtensions)FeatureLayer;
LayerExtensions.AddExtension(new XYDataSourcePageExtensionClass());
//Add it to the MXD
Map.AddLayer(FeatureLayer);
FeatureLayer.Selectable = true;
MxDocument.UpdateContents();
MxDocument.ActiveView.Refresh();
This is from a function in a class that is called from the UI Form. What I am doing is creating a CSV file from a .Net DataTable (not in the above code), adding the CSV as a Table in Sources of the TOC, and them mapping the Table as Layer (the last 4 lines above). This all works fine if I do it on the main UI thread of the Form when the user clicks a button. But what I would like to do is it put it on a TPL thread since it can be a time consuming process and here is when I run into problems. The above code will CRASH arcmap completely. It cannot even be trapped. I noticed two things. One, the crash happens on the line "Map.AddLayer(FeatureLayer);" so when it tries to add to the layer. So I removed that line just to see what the Table in sources looks like. Second, looking at that Table I notice that if I right click it the options to Open and Display are lit-up for a second and then grey out. Again, this only happens when on a Thread. Another thing to note is that when I break on any of the lines of code above in the Thread and inspect the objects I get an error "The function evaluation requires all threads to run". I would think this is more an issue with Visual Studio and the implicit evaluation settings so it should not affect arcmap and it certainly should not cause it to crash. But I thought I would mention it. Thanks for any help. Ernie
... View more
12-05-2013
04:51 AM
|
0
|
0
|
665
|
POST
|
Jennifer, there is another thread on the forum where they posted a replacement for idatastatistics which you could probably implement pretty easily. My code in VBA so I just rewrote it from scratch but since you are using .net you might find it useful. Ernie
... View more
06-28-2013
12:17 PM
|
0
|
0
|
785
|
POST
|
Hi Everyone. We finally upgraded to AGS 10.1 and are switching over our web services. One issue I am running into is using the layers as WMS with a Proxy file (one of many error actually but I have gotten around the others). Using SL 5 and version 3.1 of the API (also tried this with SL 4 and api 3.0 but upgraded to see if it made a difference). Prior to 10.1, I had a bunch of different layer types load in our SL app - Dynamic, Tiled and WMS. Also had a proxy file sitting on the same server in the the app (ie ./Proxy/proxy.ashx and proxy.config). Everything worked fine, I added url stems to the proxy file with a match all set. So for example: <serverItem url="http://serverx/" matchAll="true" /> In this case the layer did not have security turned on but we have to add an entry for it anyway - which worked fine. Now, with 10.1, I keep getting a "not found" error bounce back from the WMS layer. I tried adjusting for the port with something like this but no dice: <serverItem url="http://serverx:6080/" matchAll="true" /> Fidder comes back with this: Non-negative number required. Parameter name: count Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Non-negative number required. Parameter name: count Source Error: Line 108: { Line 109: BinaryReader br = new BinaryReader(byteStream); Line 110: byte[] outb = br.ReadBytes((int)serverResponse.ContentLength); Line 111: br.Close(); Line 112: Source File: c:\....\Proxy\proxy.ashx Line: 110 Stack Trace: [ArgumentOutOfRangeException: Non-negative number required. Parameter name: count] System.IO.BinaryReader.ReadBytes(Int32 count) +14387194 proxy.ProcessRequest(HttpContext context) in c:\....l\Proxy\proxy.ashx:110 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +913 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165 If I disable the code that sets t he Proxy in the WMSLayer.ProxyUrl property everything works fine. Any insight? Thanks Ernie
... View more
06-07-2013
06:03 AM
|
0
|
1
|
2115
|
POST
|
What about something similar to this: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#NavigationActions You will just need to prompt the user for an X/Y, create an envelop, and do a zoom or pan. For the popup, you could probably do all that in XAML as a user control. Or if you prefer code: http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup%28v=vs.95%29.aspx Ernie
... View more
06-07-2013
03:28 AM
|
0
|
0
|
251
|
POST
|
Has anyone been able to figure this out? I have the same problem with Spatial Reference: 102711 vs 3424. I create a layer in 10.1 and it says "Spatial Reference: 102711 (3424)" so now my silverlight fails to load the layer because it expects 3424 but see 102711. Really annoying. I tried WMS but can seem to figure out how to form the request right. Thanks Ernie
... View more
06-05-2013
09:49 AM
|
0
|
0
|
564
|
POST
|
Thanks for all of the good info guys. I am have the same problem with 10.1 in SP1. Is anyone from ESRI reading this? Since its been 3 months since the issue was acknowledged, can we get at least a yes or know if it will be fixed? If it will be, would appreciate any info on when. If not, please tell us so we can make other arrangements. I could implement the work around but that is going to require some significant beta testing before I release it to the wild since it is a critical part of the code we have. Hate to do if it a fix is in the works. Thanks Ernie
... View more
02-08-2013
10:06 AM
|
0
|
0
|
246
|
POST
|
Murathi, who's issue are you referring to? Dales or mine's? If it is mine, in one of the two links I posted there is talk about a workout. Basically, they created code for their own version of the DataStatistics tool. Ernie
... View more
02-08-2013
10:00 AM
|
0
|
0
|
785
|
POST
|
Think I might know what the problem. Seems to be something with IDataStatistics: http://forums.arcgis.com/threads/70997-ICursor-issue-in-10.1-SP-1 http://forums.arcgis.com/threads/71895-Issues-with-ArcObjects-and-ArcGIS-10.1-SP1-IDataStatistics Their symptoms match mine exactly. Hopefully ESRI issues a Hot Fix soon. Ernie
... View more
02-06-2013
10:43 AM
|
0
|
0
|
785
|
POST
|
Hi Guys. I am working an an extension for ArcGIS Desktop in Visual Studios and .net 4.0. I Have created a working shell with a few buttons and some basic code to make sure everything will work as I like and am stuck on one last thing. I would like to add a combo box to the toolbar (like the Map Scale drop down in the "Standard" toolbar of arc). I found the form-based sample solution provided by ESRI called GraphicsLayerToolControl which has been a big help. But here is where I am stuck. I am trying to do it all in WPF and the MVVM pattern. I created a UserControl like in the sample but when I try to complete the command class for it I cannot properly build the required hWnd property. Since this is WPF there is no native handle to be had. I thought I could use the Interop function HwndSource.FromVisual to get it but that comes back null. I think the problem is there is no equivalent "CreateControl()" function in WPF that the forms-based example relies on to force creation of the control This is what that looks like: public int hWnd
{
get
{
//pass the handle of the usercontrol
if (null == m_graphicsLayerListCtrl)
{
m_graphicsLayerListCtrl = new GraphicsLayersListCtrl();
m_graphicsLayerListCtrl.CreateControl(); //CANNOT FIND ANYTHING SIMILAR IN WPF
}
return m_graphicsLayerListCtrl.Handle.ToInt32();
}
} Is there a way to make this work or am I forced to do a forms-based usercontrol? Thanks Ernie
... View more
01-25-2013
03:19 AM
|
0
|
0
|
382
|
POST
|
Hi Guys. With a new extension I am creating in ArcMap using Visual Studios, I want to be able to save user settings in the user.config file. Using the built in functionality of VS, I get this as a path to user.config when I do my first save: C:\Users\<USERNAME>\AppData\Local\ESRI\DefaultDomain_Path_csldzz....\10.1.1.3143\user.config The part that is after Local is what I am concerned with. The ESRI is the company name which is used, I assume, because the extension is actually ran in ArcMap so even thought I have a company created in the extension it will use the EXE's company. After the company name is what I am really curious about. It is suppose to be based on <App Name>_<Evidence Type>_<Evidence Hash>\<Version>. Where does "DefaultDomain" come from? I assume somewhere in ArcMap but can that be changed without having to modify Arc itself? Thanks Ernie
... View more
01-24-2013
05:50 AM
|
0
|
0
|
535
|
POST
|
Nevermind, I figured it out. Had to remove the version reference in the arcmap.config file: http://gis.stackexchange.com/questions/13606/why-cant-the-breakpoint-be-hit-when-debugging-an-arcgis-10-add-in#16206 Ernie
... View more
01-23-2013
12:09 PM
|
0
|
0
|
1017
|
POST
|
Hi guys. Trying to create a new extension for ArcMap and am having trouble getting debugging to work. I can get the extension - a toolbar with buttons and code of course - to loadup in arc properly and I can click the button and fire the code. Everything seems to work but the thing I cannot get to work are breakpoints in VS. I keep getting "Debugging information for 'ArcMap.exe' cannot be found or does not match. Cannot find or open the PDB file. Here are the steps I went through: 1. Under Tools>Options of VS, I added an entry for 'http://downloads2.esri.com/Support/symbols/' in the Debugging>Symbols section and I gave it an explict path to cache to. This seems to work as I get a whole bunch PDB files downloaded related to ESRI DLLs (nothing about the actual arcmap.exe file). 2. In the Project Properties>Debug screen I set the radio to "Start external program" and point it at the arcmap.exe file. 3. Without "Enable unmanaged code debugging" at the bottom check everything loads without error and debugging does not work. With that option checked, I get the error about not finding the ArcMap.exe pdb file but debugging still does not work. Any insight? Thanks Ernie
... View more
01-23-2013
10:32 AM
|
0
|
1
|
5700
|
POST
|
Thanks for the response Dale. I am not expecting miracles with my situation being the ESRI is getting away from VBA. Yours is at least .net so you might get something. Good luck. Ernie
... View more
01-22-2013
02:52 AM
|
0
|
0
|
785
|
POST
|
Hi Everyone. I know getting an answer to this one is probably a long shot at best but I figured i would ask. We are finally getting around to upgrading to 10.1 now that SP1 is out. But it seems with SP1, something is causing ArcMap to crash completely after our custom VBA completes. In is not on every computer and it can come and go. But we are pretty certain that removing SP1 fixes it when a computer does have the problem. Debugging the VBA seems to indicate that the problem occurs right when the code completes and focus is given back to ArcMap. Happens on both 32 and 64 bit os with different hardware specs. We are looking to migrate our tools to .net but that is going to be a little while so we need to have these tools continue to work for a little while. Anyone else see something similar? Below is one of the few times we were able to get a crash report. Thanks Ernie Faulting application name: ArcMap.exe, version: 10.1.1.3143, time stamp: 0x5058f74e Faulting module name: ntdll.dll, version: 6.1.7601.17725, time stamp: 0x4ec49b8f Exception code: 0xc0000374 Fault offset: 0x000ce6c3 Faulting process id: 0xd0c Faulting application start time: 0x01cdf4c13555ce57 Faulting application path: C:\Program Files (x86)\ArcGIS\Desktop10.1\bin\ArcMap.exe Faulting module path: C:\Windows\SysWOW64\ntdll.dll Report Id: b050bd23-60b4-11e2-b5ac-002219ed304c
... View more
01-18-2013
05:25 AM
|
0
|
8
|
3122
|
POST
|
Nevermind. Had to add "LAYERS=Natural2007" to the url string AND i had to also set not on the URL property of the WMSLayer but also the MapURL property. Ernie
... View more
08-30-2012
04:00 AM
|
0
|
0
|
293
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|