POST
|
Here is a better solution than the code I posted previously. The Microsoft csm.dll library will only get loaded if Remote Debugging is enabled in the process. This can be disabled if you don't need that feature by adding a section to the application configuration file: <configuration>
<system.diagnostics>
<switches>
<add name="Remote.Disable" value="1" />
</switches>
</system.diagnostics>
</configuration>
... View more
05-16-2013
12:11 PM
|
1
|
0
|
1941
|
POST
|
These errors may be caused by a module conflict between CSM.dll in the ArcGIS BIN folder and a Microsoft library (VS7 Causality Stack Manager) also named csm.dll that's usually found in %commonprogramfiles%\Microsoft Shared\VS7Debug. The ESRI module is a raster-related library while the Microsoft module appears to be related to remote debugging of web service code. I discovered the conflict in an application that communcates with a web service using a class derived from System.Web.Services.Protocols.SoapHttpClientProtocol and later tries to load an image server layer which throws an AccessViolationException from ESRI.ArcGIS.Carto.IImageServerLayer.Initialize method. This was only happening when the Visual Studio debugger was attached, and only if the .Net web service code executed before loading the image server layer. I worked out a hack that resolved the problem in my test case, perhaps an adaptation of this code might help others finding similar problems:
/// <summary>
/// Loads the CSM.dll from ArcGIS BIN path in case the process wants to load the Microsoft library of same name.
/// Call this method as early as possible to be effective (e.g. main form OnLoad, program's entry point method).
/// </summary>
private static void PreLoadEsriCSM(bool debugOnly)
{
if (!debugOnly || System.Diagnostics.Debugger.IsAttached)
{
string path = System.IO.Path.Combine(ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path, "Bin\\CSM.dll");
if (System.IO.File.Exists(path))
{
bool isConflict = false;
bool isMatch = false;
using (var p = System.Diagnostics.Process.GetCurrentProcess())
{
foreach (System.Diagnostics.ProcessModule m in p.Modules)
{
if (m.ModuleName.ToLower() == "csm.dll")
{
if (path.ToLower() != m.FileName.ToLower())
isConflict = true;
else
{
isMatch = true;
break;
}
}
}
}
if (isConflict && !isMatch)
System.Diagnostics.Debug.WriteLine("It may be necessary to call this method earlier to be effective.");
if (!isMatch)
LoadLibrary(path);
}
}
}
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
internal static extern IntPtr LoadLibrary(string dllname);
... View more
05-14-2013
03:33 PM
|
1
|
1
|
1941
|
Title | Kudos | Posted |
---|---|---|
1 | 05-14-2013 03:33 PM | |
1 | 05-16-2013 12:11 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|