axSymbologyControl - can't load ESRI.ServerStyle

814
4
05-17-2011 02:21 AM
AnatoliiTerentiev
Occasional Contributor III
In exampe of how to use LayerRendering code
            string sInstall = ReadRegistry("SOFTWARE\\ESRI\\CoreRuntime");
            axSymbologyControl1.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle");

worked. But in my program the same code does not work, when loadStyleFile I  get error message
"(Exception -  HRESULT: 0x80004005 (E_FAIL))". Error code - -2147467259.
stack trace -
"   ? System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)\r\n   ? ESRI.ArcGIS.Controls.ISymbologyControlDefault.LoadStyleFile(String fileName)\r\n   ? ESRI.ArcGIS.Controls.AxSymbologyControl.LoadStyleFile(String fileName)\r\n   ? monitor.KartaForm.KartaForm_Load(Object sender, EventArgs e) ? D:\\VS2005\\Projects\\monitor\\monitor\\KareliaForm.cs:???????? 398\r\n   ? System.Windows.Forms.Form.OnLoad(EventArgs e)\r\n   ? System.Windows.Forms.Form.SetVisibleCore(Boolean value)\r\n   ? System.Windows.Forms.Control.Show()\r\n   ? monitor.Form1.ShowKarta() ? D:\\VS2005\\Projects\\monitor\\monitor\\Form1.cs:???????? 199\r\n   ? monitor.Form1.Form1_Load(Object sender, EventArgs e) ? D:\\VS2005\\Projects\\monitor\\monitor\\Form1.cs:???????? 151\r\n   ? System.Windows.Forms.Form.OnLoad(EventArgs e)\r\n   ? System.Windows.Forms.Form.OnCreateControl()\r\n   ? System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r\n   ? System.Windows.Forms.Control.CreateControl()\r\n   ? System.Windows.Forms.Control.WmShowWindow(Message& m)\r\n   ? System.Windows.Forms.Control.WndProc(Message& m)\r\n   ? System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r\n   ? System.Windows.Forms.ContainerControl.WndProc(Message& m)\r\n   ? System.Windows.Forms.Form.WmShowWindow(Message& m)\r\n   ? System.Windows.Forms.Form.WndProc(Message& m)\r\n   ? System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n   ? System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n   ? System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n   ? System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)\r\n   ? System.Windows.Forms.Form.SetVisibleCore(Boolean value)\r\n   ? System.Windows.Forms.Control.set_Visible(Boolean value)\r\n   ? System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n   ? System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n   ? System.Windows.Forms.Application.Run(Form mainForm)\r\n   ? monitor.Program.Main() ? D:\\VS2005\\Projects\\monitor\\monitor\\Program.cs:???????? 17\r\n   ? System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   ? System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   ? Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   ? System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   ? System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   ? System.Threading.ThreadHelper.ThreadStart()"

Can anybody say - how to improve situation?
Thanks!
0 Kudos
4 Replies
RichardWatson
Frequent Contributor
Does your program perform the same setup/initialization as the program that works?

Starting with version 10, you have to do some additional initialization before you can use ArcObjects.  If you look at the help it is described there.

If it isn't initialization then the only other thing that I can think of is permissions.  For example, make sure that no other process has the file locked and that you have the required permissions.
0 Kudos
AnatoliiTerentiev
Occasional Contributor III
If I create new project - all works. But if I create axSymbologyControl  in current project - not works. I try put new object axSymbologyControl1 on the Form1, and try following code
        public Form1()
        {
            InitializeComponent();
            axSymbologyControl1.LoadStyleFile("C:\\Program Files\\ArcGIS\\Styles\\ESRI.ServerStyle");

        }

but receive the previous message. If I load style file in design mode, in Property Form  of axSymbologyControl ( in current project - all works too).
0 Kudos
AnatoliiTerentiev
Occasional Contributor III
I do the copy ESRY.serverStyle file in ESRY1.serverStyle and try load it. All works. I think the problem is in unvisible  process, which block ESRY.serverStyle file.  In axMapControl1 I set map document property in design mode - may be it use server style file and block it in form constructor.
0 Kudos
RichardWatson
Frequent Contributor
We use server style files and had various locking problems with them.  You can see who has the lock by running http://live.sysinternals.com/procexp.exe.  Just use the "Find / Find Handle or DLL..." command and search for the name.

The way that we worked around this problem was to explicitly make the server style files read-only in the file properties.  What would happen is that various ESRI routines open the files with write mode if they can and the first one succeeds and then the others are blocked.

Good luck!
0 Kudos